mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Allow export map entries to remap back to input files for a program (#47925)
* Allow export map entries to remap back to input files for a program * Fix file casing issues on windows * Implement abiguity error, doesnt quite work * Refine selection logic in error case to use getCommonSourceDirectory, add more tests
This commit is contained in:
parent
1e157ef1b2
commit
8e433cda3d
@ -1511,6 +1511,15 @@
|
||||
"code": 2207
|
||||
},
|
||||
|
||||
"The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate.": {
|
||||
"category": "Error",
|
||||
"code": 2209
|
||||
},
|
||||
"The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate.": {
|
||||
"category": "Error",
|
||||
"code": 2210
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
|
||||
@ -86,14 +86,15 @@ namespace ts {
|
||||
return { fileName: resolved.path, packageId: resolved.packageId };
|
||||
}
|
||||
|
||||
function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean | undefined, failedLookupLocations: string[], resultFromCache: ResolvedModuleWithFailedLookupLocations | undefined): ResolvedModuleWithFailedLookupLocations {
|
||||
function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean | undefined, failedLookupLocations: string[], diagnostics: Diagnostic[], resultFromCache: ResolvedModuleWithFailedLookupLocations | undefined): ResolvedModuleWithFailedLookupLocations {
|
||||
if (resultFromCache) {
|
||||
resultFromCache.failedLookupLocations.push(...failedLookupLocations);
|
||||
return resultFromCache;
|
||||
}
|
||||
return {
|
||||
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport, packageId: resolved.packageId },
|
||||
failedLookupLocations
|
||||
failedLookupLocations,
|
||||
resolutionDiagnostics: diagnostics
|
||||
};
|
||||
}
|
||||
|
||||
@ -107,6 +108,8 @@ namespace ts {
|
||||
packageJsonInfoCache: PackageJsonInfoCache | undefined;
|
||||
features: NodeResolutionFeatures;
|
||||
conditions: string[];
|
||||
requestContainingDirectory: string | undefined;
|
||||
reportDiagnostic: DiagnosticReporter;
|
||||
}
|
||||
|
||||
/** Just the fields that we use for module resolution. */
|
||||
@ -354,7 +357,18 @@ namespace ts {
|
||||
features |= NodeResolutionFeatures.EsmMode;
|
||||
}
|
||||
const conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
||||
const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features, conditions };
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const moduleResolutionState: ModuleResolutionState = {
|
||||
compilerOptions: options,
|
||||
host,
|
||||
traceEnabled,
|
||||
failedLookupLocations,
|
||||
packageJsonInfoCache: cache,
|
||||
features,
|
||||
conditions,
|
||||
requestContainingDirectory: containingDirectory,
|
||||
reportDiagnostic: diag => void diagnostics.push(diag),
|
||||
};
|
||||
let resolved = primaryLookup();
|
||||
let primary = true;
|
||||
if (!resolved) {
|
||||
@ -374,7 +388,7 @@ namespace ts {
|
||||
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
||||
};
|
||||
}
|
||||
result = { resolvedTypeReferenceDirective, failedLookupLocations };
|
||||
result = { resolvedTypeReferenceDirective, failedLookupLocations, resolutionDiagnostics: diagnostics };
|
||||
perFolderCache?.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
||||
if (traceEnabled) traceResult(result);
|
||||
return result;
|
||||
@ -468,6 +482,8 @@ namespace ts {
|
||||
packageJsonInfoCache: cache?.getPackageJsonInfoCache(),
|
||||
conditions: emptyArray,
|
||||
features: NodeResolutionFeatures.None,
|
||||
requestContainingDirectory: containingDirectory,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
|
||||
return forEachAncestorDirectory(containingDirectory, ancestorDirectory => {
|
||||
@ -1317,6 +1333,7 @@ namespace ts {
|
||||
conditions.pop();
|
||||
}
|
||||
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const state: ModuleResolutionState = {
|
||||
compilerOptions,
|
||||
host,
|
||||
@ -1325,10 +1342,12 @@ namespace ts {
|
||||
packageJsonInfoCache: cache,
|
||||
features,
|
||||
conditions,
|
||||
requestContainingDirectory: containingDirectory,
|
||||
reportDiagnostic: diag => void diagnostics.push(diag),
|
||||
};
|
||||
|
||||
const result = forEach(extensions, ext => tryResolve(ext));
|
||||
return createResolvedModuleWithFailedLookupLocations(result?.value?.resolved, result?.value?.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
|
||||
return createResolvedModuleWithFailedLookupLocations(result?.value?.resolved, result?.value?.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
|
||||
|
||||
function tryResolve(extensions: Extensions): SearchResult<{ resolved: Resolved, isExternalLibraryImport: boolean }> {
|
||||
const loader: ResolutionKindSpecificLoader = (extensions, candidate, onlyRecordFailures, state) => nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true);
|
||||
@ -1516,9 +1535,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function loadJSOrExactTSFileName(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined {
|
||||
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && isDeclarationFileName(candidate)) {
|
||||
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) {
|
||||
const result = tryFile(candidate, onlyRecordFailures, state);
|
||||
return result !== undefined ? { path: candidate, ext: forEach(supportedDeclarationExtensions, e => fileExtensionIs(candidate, e) ? e : undefined)! } : undefined;
|
||||
return result !== undefined ? { path: candidate, ext: tryExtractTSExtension(candidate) as Extension } : undefined;
|
||||
}
|
||||
|
||||
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
||||
@ -1655,6 +1674,8 @@ namespace ts {
|
||||
packageJsonInfoCache: cache?.getPackageJsonInfoCache(),
|
||||
conditions: ["node", "require", "types"],
|
||||
features,
|
||||
requestContainingDirectory: packageJsonInfo.packageDirectory,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
const requireResolution = loadNodeModuleFromDirectoryWorker(
|
||||
extensions,
|
||||
@ -1764,6 +1785,8 @@ namespace ts {
|
||||
packageJsonInfoCache: PackageJsonInfoCache | undefined;
|
||||
features: number;
|
||||
conditions: never[];
|
||||
requestContainingDirectory: string | undefined;
|
||||
reportDiagnostic: DiagnosticReporter
|
||||
} = {
|
||||
host,
|
||||
compilerOptions: options,
|
||||
@ -1772,6 +1795,8 @@ namespace ts {
|
||||
packageJsonInfoCache,
|
||||
features: 0,
|
||||
conditions: [],
|
||||
requestContainingDirectory: undefined,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
const parts = getPathComponents(fileName);
|
||||
parts.pop();
|
||||
@ -2112,8 +2137,9 @@ namespace ts {
|
||||
}
|
||||
return toSearchResult(/*value*/ undefined);
|
||||
}
|
||||
const finalPath = getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, state.host.getCurrentDirectory?.());
|
||||
|
||||
const finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
||||
const inputLink = tryLoadInputFileForPath(finalPath, subpath, combinePaths(scope.packageDirectory, "package.json"), isImports);
|
||||
if (inputLink) return inputLink;
|
||||
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
||||
}
|
||||
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
||||
@ -2154,6 +2180,134 @@ namespace ts {
|
||||
trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
||||
}
|
||||
return toSearchResult(/*value*/ undefined);
|
||||
|
||||
function toAbsolutePath(path: string): string;
|
||||
function toAbsolutePath(path: string | undefined): string | undefined;
|
||||
function toAbsolutePath(path: string | undefined): string | undefined {
|
||||
if (path === undefined) return path;
|
||||
return hostGetCanonicalFileName({ useCaseSensitiveFileNames })(getNormalizedAbsolutePath(path, state.host.getCurrentDirectory?.()));
|
||||
}
|
||||
|
||||
function combineDirectoryPath(root: string, dir: string) {
|
||||
return ensureTrailingDirectorySeparator(combinePaths(root, dir));
|
||||
}
|
||||
|
||||
function useCaseSensitiveFileNames() {
|
||||
return !state.host.useCaseSensitiveFileNames ? true :
|
||||
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
|
||||
state.host.useCaseSensitiveFileNames();
|
||||
}
|
||||
|
||||
function tryLoadInputFileForPath(finalPath: string, entry: string, packagePath: string, isImports: boolean) {
|
||||
// Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
|
||||
// PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure
|
||||
// we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving!
|
||||
// _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!).
|
||||
// We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups.
|
||||
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
|
||||
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
|
||||
&& finalPath.indexOf("/node_modules/") === -1
|
||||
&& (state.compilerOptions.configFile ? startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)
|
||||
) {
|
||||
// So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
|
||||
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
|
||||
// `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
|
||||
|
||||
const getCanonicalFileName = hostGetCanonicalFileName({ useCaseSensitiveFileNames });
|
||||
const commonSourceDirGuesses: string[] = [];
|
||||
// A `rootDir` compiler option strongly indicates the root location
|
||||
// A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations
|
||||
if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
|
||||
const commonDir = toAbsolutePath(getCommonSourceDirectory(state.compilerOptions, () => [], state.host.getCurrentDirectory?.() || "", getCanonicalFileName));
|
||||
commonSourceDirGuesses.push(commonDir);
|
||||
}
|
||||
else if (state.requestContainingDirectory) {
|
||||
// However without either of those set we're in the dark. Let's say you have
|
||||
//
|
||||
// ./tools/index.ts
|
||||
// ./src/index.ts
|
||||
// ./dist/index.js
|
||||
// ./package.json <-- references ./dist/index.js
|
||||
// ./tsconfig.json <-- loads ./src/index.ts
|
||||
//
|
||||
// How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
|
||||
// Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from
|
||||
// without more context.
|
||||
// But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too
|
||||
// must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
|
||||
|
||||
const requestingFile = toAbsolutePath(combinePaths(state.requestContainingDirectory, "index.ts"));
|
||||
// And we can try every folder above the common folder for the request folder and the config/package base directory
|
||||
// This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
|
||||
// know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
|
||||
// else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
|
||||
// be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
|
||||
// logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
|
||||
// internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
|
||||
const commonDir = toAbsolutePath(getCommonSourceDirectory(state.compilerOptions, () => [requestingFile, toAbsolutePath(packagePath)], state.host.getCurrentDirectory?.() || "", getCanonicalFileName));
|
||||
commonSourceDirGuesses.push(commonDir);
|
||||
|
||||
let fragment = ensureTrailingDirectorySeparator(commonDir);
|
||||
while (fragment && fragment.length > 1) {
|
||||
const parts = getPathComponents(fragment);
|
||||
parts.pop(); // remove a directory
|
||||
const commonDir = getPathFromPathComponents(parts);
|
||||
commonSourceDirGuesses.unshift(commonDir);
|
||||
fragment = ensureTrailingDirectorySeparator(commonDir);
|
||||
}
|
||||
}
|
||||
if (commonSourceDirGuesses.length > 1) {
|
||||
state.reportDiagnostic(createCompilerDiagnostic(
|
||||
isImports
|
||||
? Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
|
||||
: Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate,
|
||||
entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
|
||||
packagePath
|
||||
));
|
||||
}
|
||||
for (const commonSourceDirGuess of commonSourceDirGuesses) {
|
||||
const candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
||||
for (const candidateDir of candidateDirectories) {
|
||||
if (startsWith(finalPath, candidateDir)) {
|
||||
// The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension
|
||||
const pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
|
||||
const possibleInputBase = combinePaths(commonSourceDirGuess, pathFragment);
|
||||
const jsAndDtsExtensions = [Extension.Mjs, Extension.Cjs, Extension.Js, Extension.Json, Extension.Dmts, Extension.Dcts, Extension.Dts];
|
||||
for (const ext of jsAndDtsExtensions) {
|
||||
if (fileExtensionIs(possibleInputBase, ext)) {
|
||||
const inputExts = getPossibleOriginalInputExtensionForExtension(possibleInputBase);
|
||||
for (const possibleExt of inputExts) {
|
||||
const possibleInputWithInputExtension = changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
|
||||
if ((extensions === Extensions.TypeScript && hasJSFileExtension(possibleInputWithInputExtension)) ||
|
||||
(extensions === Extensions.JavaScript && hasTSFileExtension(possibleInputWithInputExtension))) {
|
||||
continue;
|
||||
}
|
||||
if (state.host.fileExists(possibleInputWithInputExtension)) {
|
||||
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
||||
function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess: string) {
|
||||
// Config file ouput paths are processed to be relative to the host's current directory, while
|
||||
// otherwise the paths are resolved relative to the common source dir the compiler puts together
|
||||
const currentDir = state.compilerOptions.configFile ? state.host.getCurrentDirectory?.() || "" : commonSourceDirGuess;
|
||||
const candidateDirectories = [];
|
||||
if (state.compilerOptions.declarationDir) {
|
||||
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
|
||||
}
|
||||
if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
|
||||
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
|
||||
}
|
||||
return candidateDirectories;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2374,12 +2528,13 @@ namespace ts {
|
||||
export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations {
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
const failedLookupLocations: string[] = [];
|
||||
const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: diag => void diagnostics.push(diag) };
|
||||
|
||||
const resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
||||
// No originalPath because classic resolution doesn't resolve realPath
|
||||
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
|
||||
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
|
||||
|
||||
function tryResolve(extensions: Extensions): SearchResult<Resolved> {
|
||||
const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
||||
@ -2424,9 +2579,10 @@ namespace ts {
|
||||
trace(host, Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
|
||||
}
|
||||
const failedLookupLocations: string[] = [];
|
||||
const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: diag => void diagnostics.push(diag) };
|
||||
const resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
||||
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
||||
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1364,6 +1364,36 @@ namespace ts {
|
||||
|
||||
return program;
|
||||
|
||||
function addResolutionDiagnostics(list: Diagnostic[] | undefined) {
|
||||
if (!list) return;
|
||||
for (const elem of list) {
|
||||
programDiagnostics.add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
function pullDiagnosticsFromCache(names: string[] | readonly FileReference[], containingFile: SourceFile) {
|
||||
if (!moduleResolutionCache) return;
|
||||
const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
||||
const containingFileMode = !isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
||||
const containingDir = getDirectoryPath(containingFileName);
|
||||
const redirectedReference = getRedirectReferenceForResolution(containingFile);
|
||||
let i = 0;
|
||||
for (const n of names) {
|
||||
// mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less
|
||||
const mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
|
||||
const name = typeof n === "string" ? n : n.fileName;
|
||||
i++;
|
||||
// only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
|
||||
// (Since diagnostics are only issued via import or export map lookup)
|
||||
// This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
|
||||
// When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
|
||||
// APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
|
||||
if (isExternalModuleNameRelative(name)) continue;
|
||||
const diags = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)?.resolutionDiagnostics;
|
||||
addResolutionDiagnostics(diags);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveModuleNamesWorker(moduleNames: string[], containingFile: SourceFile, reusedNames: string[] | undefined): readonly ResolvedModuleFull[] {
|
||||
if (!moduleNames.length) return emptyArray;
|
||||
const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
||||
@ -1374,6 +1404,7 @@ namespace ts {
|
||||
performance.mark("afterResolveModule");
|
||||
performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
||||
tracing?.pop();
|
||||
pullDiagnosticsFromCache(moduleNames, containingFile);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -6717,6 +6717,8 @@ namespace ts {
|
||||
readonly resolvedModule: ResolvedModuleFull | undefined;
|
||||
/* @internal */
|
||||
readonly failedLookupLocations: string[];
|
||||
/* @internal */
|
||||
readonly resolutionDiagnostics: Diagnostic[]
|
||||
}
|
||||
|
||||
export interface ResolvedTypeReferenceDirective {
|
||||
@ -6738,6 +6740,8 @@ namespace ts {
|
||||
export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined;
|
||||
readonly failedLookupLocations: string[];
|
||||
/* @internal */
|
||||
resolutionDiagnostics: Diagnostic[]
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@ -4387,6 +4387,16 @@ namespace ts {
|
||||
Extension.Dts;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is an inverse of `getDeclarationEmitExtensionForPath`.
|
||||
*/
|
||||
export function getPossibleOriginalInputExtensionForExtension(path: string) {
|
||||
return fileExtensionIsOneOf(path, [Extension.Dmts, Extension.Mjs, Extension.Mts]) ? [Extension.Mts, Extension.Mjs] :
|
||||
fileExtensionIsOneOf(path, [Extension.Dcts, Extension.Cjs, Extension.Cts]) ? [Extension.Cts, Extension.Cjs]:
|
||||
fileExtensionIsOneOf(path, [`.json.d.ts`]) ? [Extension.Json] :
|
||||
[Extension.Tsx, Extension.Ts, Extension.Jsx, Extension.Js];
|
||||
}
|
||||
|
||||
export function outFile(options: CompilerOptions) {
|
||||
return options.outFile || options.out;
|
||||
}
|
||||
|
||||
@ -215,6 +215,7 @@ namespace ts {
|
||||
extension: Extension.Ts,
|
||||
},
|
||||
failedLookupLocations: [],
|
||||
resolutionDiagnostics: [],
|
||||
});
|
||||
assert.isDefined(cache.get("/sub"));
|
||||
assert.isUndefined(cache.get("/"));
|
||||
@ -228,6 +229,7 @@ namespace ts {
|
||||
extension: Extension.Ts,
|
||||
},
|
||||
failedLookupLocations: [],
|
||||
resolutionDiagnostics: [],
|
||||
});
|
||||
assert.isDefined(cache.get("/sub/dir/foo"));
|
||||
assert.isDefined(cache.get("/sub/dir"));
|
||||
@ -243,6 +245,7 @@ namespace ts {
|
||||
extension: Extension.Ts,
|
||||
},
|
||||
failedLookupLocations: [],
|
||||
resolutionDiagnostics: [],
|
||||
});
|
||||
assert.isDefined(cache.get("/foo/bar"));
|
||||
assert.isDefined(cache.get("/foo"));
|
||||
@ -257,6 +260,7 @@ namespace ts {
|
||||
extension: Extension.Ts,
|
||||
},
|
||||
failedLookupLocations: [],
|
||||
resolutionDiagnostics: [],
|
||||
});
|
||||
assert.isDefined(cache.get("/foo"));
|
||||
assert.isUndefined(cache.get("/"));
|
||||
@ -270,6 +274,7 @@ namespace ts {
|
||||
extension: Extension.Ts,
|
||||
},
|
||||
failedLookupLocations: [],
|
||||
resolutionDiagnostics: [],
|
||||
});
|
||||
assert.isDefined(cache.get("c:/foo"));
|
||||
assert.isDefined(cache.get("c:/"));
|
||||
@ -279,6 +284,7 @@ namespace ts {
|
||||
cache.set("/foo/bar/baz", {
|
||||
resolvedModule: undefined,
|
||||
failedLookupLocations: [],
|
||||
resolutionDiagnostics: [],
|
||||
});
|
||||
assert.isDefined(cache.get("/foo/bar/baz"));
|
||||
assert.isDefined(cache.get("/foo/bar"));
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as self from "package";
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as self from "package";
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
@ -6,6 +7,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
@ -6,6 +7,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "#cjs";
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "#cjs";
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/index.ts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/index.ts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
@ -8,6 +9,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471:
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/index.ts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
@ -8,6 +9,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471:
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/index.ts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
@ -6,6 +7,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303:
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/index.ts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
@ -6,6 +7,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303:
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/conformance/node/index.ts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "package/cjs";
|
||||
|
||||
25
tests/baselines/reference/nodeNextPackageImportMapRootDir.js
Normal file
25
tests/baselines/reference/nodeNextPackageImportMapRootDir.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageImportMapRootDir.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"imports": {
|
||||
"#dep": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
import * as me from "#dep";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
import * as me from "#dep";
|
||||
me.thing();
|
||||
export function thing() { }
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "#dep";
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "#dep";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/compiler/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/compiler/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/compiler/package.json (0 errors) ====
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
==== tests/cases/compiler/index.ts (0 errors) ====
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDir.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function thing() { }
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/compiler/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/compiler/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/compiler/package.json (0 errors) ====
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
==== tests/cases/compiler/index.ts (0 errors) ====
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function thing() { }
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export declare function thing(): void;
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function thing() { }
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export declare function thing(): void;
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
//// [thing.ts]
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function srcthing(): void {}
|
||||
|
||||
|
||||
|
||||
//// [thing.js]
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function srcthing() { }
|
||||
|
||||
|
||||
//// [thing.d.ts]
|
||||
export declare function srcthing(): void;
|
||||
@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/src/thing.ts ===
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(thing.ts, 7, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(me.thing, Decl(index.ts, 0, 8))
|
||||
>me : Symbol(me, Decl(thing.ts, 7, 6))
|
||||
>thing : Symbol(me.thing, Decl(index.ts, 0, 8))
|
||||
|
||||
export function srcthing(): void {}
|
||||
>srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11))
|
||||
|
||||
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
>srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11))
|
||||
>thing : Symbol(thing, Decl(index.ts, 0, 8))
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/src/thing.ts ===
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function srcthing(): void {}
|
||||
>srcthing : () => void
|
||||
|
||||
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
>srcthing : () => void
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/compiler/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
|
||||
|
||||
!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/compiler/package.json'. Supply the `rootDir` compiler option to disambiguate.
|
||||
==== tests/cases/compiler/tsconfig.json (0 errors) ====
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"outDir": "./dist",
|
||||
"declarationDir": "./types",
|
||||
"declaration": true
|
||||
}
|
||||
}
|
||||
==== tests/cases/compiler/src/thing.ts (0 errors) ====
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function srcthing(): void {}
|
||||
|
||||
|
||||
==== tests/cases/compiler/package.json (0 errors) ====
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
==== tests/cases/compiler/index.ts (0 errors) ====
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
//// [thing.ts]
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function srcthing(): void {}
|
||||
|
||||
|
||||
|
||||
//// [thing.js]
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function srcthing() { }
|
||||
|
||||
|
||||
//// [thing.d.ts]
|
||||
export declare function srcthing(): void;
|
||||
@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/src/thing.ts ===
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(thing.ts, 7, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(me.thing, Decl(index.ts, 0, 8))
|
||||
>me : Symbol(me, Decl(thing.ts, 7, 6))
|
||||
>thing : Symbol(me.thing, Decl(index.ts, 0, 8))
|
||||
|
||||
export function srcthing(): void {}
|
||||
>srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11))
|
||||
|
||||
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
>srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11))
|
||||
>thing : Symbol(thing, Decl(index.ts, 0, 8))
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/src/thing.ts ===
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function srcthing(): void {}
|
||||
>srcthing : () => void
|
||||
|
||||
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
>srcthing : () => void
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function thing() { }
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export declare function thing(): void;
|
||||
@ -0,0 +1,12 @@
|
||||
=== /pkg/src/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== /pkg/src/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : () => void
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
//// [tests/cases/compiler/nodeNextPackageSelfNameWithOutDirRootDir.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
//// [index.ts]
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function thing() { }
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
|
||||
me.thing();
|
||||
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
>me : Symbol(me, Decl(index.ts, 0, 6))
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : Symbol(thing, Decl(index.ts, 2, 11))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as me from "@this/package";
|
||||
>me : typeof me
|
||||
|
||||
me.thing();
|
||||
>me.thing() : void
|
||||
>me.thing : () => void
|
||||
>me : typeof me
|
||||
>thing : () => void
|
||||
|
||||
export function thing(): void {}
|
||||
>thing : () => void
|
||||
|
||||
20
tests/cases/compiler/nodeNextPackageImportMapRootDir.ts
Normal file
20
tests/cases/compiler/nodeNextPackageImportMapRootDir.ts
Normal file
@ -0,0 +1,20 @@
|
||||
// @module: nodenext
|
||||
// @outDir: ./dist
|
||||
// @rootDir: tests/cases/compiler
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"imports": {
|
||||
"#dep": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
import * as me from "#dep";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
16
tests/cases/compiler/nodeNextPackageSelfNameWithOutDir.ts
Normal file
16
tests/cases/compiler/nodeNextPackageSelfNameWithOutDir.ts
Normal file
@ -0,0 +1,16 @@
|
||||
// @module: nodenext
|
||||
// @outDir: ./dist
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
@ -0,0 +1,21 @@
|
||||
// @module: nodenext
|
||||
// @outDir: ./dist
|
||||
// @declarationDir: ./types
|
||||
// @declaration: true
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
@ -0,0 +1,26 @@
|
||||
// @filename: tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"outDir": "./dist",
|
||||
"declarationDir": "./types",
|
||||
"composite": true
|
||||
}
|
||||
}
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
@ -0,0 +1,37 @@
|
||||
// @noImplicitReferences: true
|
||||
// @filename: tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"outDir": "./dist",
|
||||
"declarationDir": "./types",
|
||||
"composite": true
|
||||
}
|
||||
}
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
// @filename: src/thing.ts
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function srcthing(): void {}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
// @noImplicitReferences: true
|
||||
// @filename: tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"outDir": "./dist",
|
||||
"declarationDir": "./types",
|
||||
"declaration": true
|
||||
}
|
||||
}
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
export {srcthing as thing} from "./src/thing.js";
|
||||
// @filename: src/thing.ts
|
||||
// The following import should cause `index.ts`
|
||||
// to be included in the build, which will,
|
||||
// in turn, cause the common src directory to not be `src`
|
||||
// (the harness is wierd here in that noImplicitReferences makes only
|
||||
// this file get loaded as an entrypoint and emitted, while on the
|
||||
// real command-line we'll crawl the imports for that set - a limitation
|
||||
// of the harness, I suppose)
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function srcthing(): void {}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
// @module: nodenext
|
||||
// @outDir: /pkg/dist
|
||||
// @declarationDir: /pkg/types
|
||||
// @declaration: true
|
||||
// @rootDir: /pkg/src
|
||||
// @filename: /pkg/package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: /pkg/src/index.ts
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
@ -0,0 +1,17 @@
|
||||
// @module: nodenext
|
||||
// @outDir: ./dist
|
||||
// @rootDir: tests/cases/compiler
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "@this/package",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
// @filename: index.ts
|
||||
import * as me from "@this/package";
|
||||
|
||||
me.thing();
|
||||
|
||||
export function thing(): void {}
|
||||
Loading…
x
Reference in New Issue
Block a user