You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The output structures of rootDir and rootDirs are inconsistent #61883
This is the behavior in every version I tried, and I reviewed the FAQ for entries about rootDirs (of which there are none). I tried next, 5.8.3 and 2.0.8. All exhibit this behaviour.
Both should do the same thing. Indeed, according to the documentation, using rootDirs ‘does not affect how TypeScript emits JavaScript’.
Additional information about the issue
For single-element arrays, of course, it doesn't really matter. But as it stands, I can't see a way to get both the non-nested structure rootDir provides and multiple root directories. #22039 perhaps suggests that setting both rootDir and rootDirs would work, but doing that makes tsc complain about whichever of rootDirs isn't in rootDir.
Confusingly, these settings are for basically completely unrelated behaviors, and are not expected to do the same thing.
rootDir determines what base directory is used to compute the output path. So if you have a file src/foo/bar/baz.ts and set rootDir to src/foo, the output path will be bar/baz.js
rootDirs is a set of directories to start relative module resolution from.
Activity
RyanCavanaugh commentedon Jun 17, 2025
Confusingly, these settings are for basically completely unrelated behaviors, and are not expected to do the same thing.
rootDirdetermines what base directory is used to compute the output path. So if you have a filesrc/foo/bar/baz.tsand setrootDirtosrc/foo, the output path will bebar/baz.jsrootDirsis a set of directories to start relative module resolution from.typescript-bot commentedon Jun 20, 2025
This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.