mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
Fix self-name input linking for --allowJs --declaration projects (#54819)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
@@ -657,6 +657,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
{
|
||||
name: "checkJs",
|
||||
type: "boolean",
|
||||
affectsModuleResolution: true,
|
||||
showInSimplifiedHelpView: true,
|
||||
category: Diagnostics.JavaScript_Support,
|
||||
description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files,
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
forEach,
|
||||
forEachAncestorDirectory,
|
||||
formatMessage,
|
||||
getAllowJSCompilerOption,
|
||||
getBaseFileName,
|
||||
GetCanonicalFileName,
|
||||
getCommonSourceDirectory,
|
||||
@@ -2420,7 +2421,16 @@ function loadModuleFromSelfNameReference(extensions: Extensions, moduleName: str
|
||||
// in order to be consistent with (non-self) library-name loading in
|
||||
// `loadModuleFromNearestNodeModulesDirectoryWorker`, which uses two passes in order
|
||||
// to prioritize `@types` packages higher up the directory tree over untyped
|
||||
// implementation packages.
|
||||
// implementation packages. See the selfNameModuleAugmentation.ts test for why this
|
||||
// matters.
|
||||
//
|
||||
// However, there's an exception. If the user has `allowJs` and `declaration`, we need
|
||||
// to ensure that self-name imports of their own package can resolve back to their
|
||||
// input JS files via `tryLoadInputFileForPath` at a higher priority than their output
|
||||
// declaration files, so we need to do a single pass with all extensions for that case.
|
||||
if (getAllowJSCompilerOption(state.compilerOptions) && !pathContainsNodeModules(directory)) {
|
||||
return loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference);
|
||||
}
|
||||
const priorityExtensions = extensions & (Extensions.TypeScript | Extensions.Declaration);
|
||||
const secondaryExtensions = extensions & ~(Extensions.TypeScript | Extensions.Declaration);
|
||||
return loadModuleFromExports(scope, priorityExtensions, subpath, state, cache, redirectedReference)
|
||||
|
||||
Reference in New Issue
Block a user