Skip to content

tsconfig paths causes module resolution to succeed and fail in the same build #50391

Closed
@kwasimensah

Description

@kwasimensah

Bug Report

I'm working in a monorepo and was trying to use tsconfig paths instead of npm link to have various packages depend on each other and it isn't working. Based on @andrewbranch's comment in #49160 (comment)

all any package author has to do is put their .d.ts files in the same directories as their .js files,

it seems like this should work and I'm getting a confusing error from --traceResolution about it not working.

🔎 Search Terms

baseUrl paths resolution

🕗 Version & Regression Information

Version 4.7.4
Version 4.6.4

Also happens with typescript@next

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about module resolution

💻 Code

Given https://github.com/kwasimensah/ubiquitous-winner

Run

npx tsc -b --traceResolution b/tsconfig.json

🙁 Actual behavior

You will see both

======== Module name 'a' was successfully resolved
b/b.ts:1:21 - error TS2307: Cannot find module 'a' or its corresponding type declarations.

1 import { foo } from "a";
                      ~~~

🙂 Expected behavior

The command is successful and a's types are found. Or a clearer error that doesn't make it seem like module resolution was successful

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions