microsoft / microsoft/TypeScript
Declaration file generation not working as expected
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 4.0.0-dev.20200429 (when trying with @next)
TypeScript Version: 3.8.0.0-dev.20200429 (when using my version ^3.8.0)
Search Terms: module resolution, lerna, monorepo, import type, declaration file
Code
Repository https://github.com/Volox/tsc-declaration-issue
To bootstrap and run:
npx lerna bootstrap
npx lerna run compile
Expected behavior: The declaration files generated are only related to the package.
Actual behavior: The declaration files are generated correctly only for lib1 and lib2 have the full tree of declaration files of both packages.

Related Issues: None that I was able to find
Notes:
The generation of declaration files is done correctly if I remove the "paths" property from tsconfig.base.json but I receive compilation errors like:
src/index.ts(1,19): error TS2307: Cannot find module 'lib1'.
src/index.ts(3,24): error TS2307: Cannot find module 'lib1/foo/bar'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the linked Volox/tsc-declaration-issue repository and run npx lerna bootstrap followed by npx lerna run compile. Compare the generated declarations for lib1 and lib2 with and without the paths property in tsconfig.base.json, while checking the reported module-resolution errors. Done means each package emits only its own declaration tree without those errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100