`getExportedDeclarations` not working with yarn PnP
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
Version: 11.0.0
I'm in the process of migrating a project to Yarn v3, including the Plug'n'Play functionality.
My project is structured as a TypeScript monorepo. The documentation is generated using `ts-morph`. Since the switch, that is failing, because `getExportedDeclarations()` is returning an empty array for re-exported types from another package of the monorepo. Many other types have become `any`.
I suspect this is because ts-morph is not compatible with Yarn PnP out of the box, but I'm not sure how to make it work to be honest.
**To Reproduce**
This is somewhat tricky to reproduce, but you can use my repo to do so.
1. clone https://github.com/zwave-js/node-zwave-js
2. check out commit `eb20fcb`
3. run `yarn add --dev ts-morph` (so yarn PnP doesn't barf at you)
4. create a file `repro.ts` with the following content in the root:
```ts
import { Project } from "ts-morph";
import { tsConfigFilePath } from "./packages/maintenance/src/tsAPITools";
const program = new Project({ tsConfigFilePath });
const file = program.getSourceFile("packages/zwave-js/src/index.ts");
const identifier = "ValueID";
const decl = file?.getExportedDeclarations().get(identifier);
debugger;
```
5. run this in a debugging console: `yarn node -r ts-node/register repro.ts`
**Expected behavior**
`decl` should be an array with length 1, including the original symbol for `ValueID`.
Contributor guide
Research direction
Read CONTRIBUTING.md, then reproduce the issue with repro.ts using packages/maintenance/src/tsAPITools and packages/zwave-js/src/index.ts. Run yarn node -r ts-node/register repro.ts and inspect getExportedDeclarations() for ValueID under Yarn PnP. Done means decl contains one original ValueID declaration instead of an empty array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100