-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getExportedDeclarations
not working with yarn PnP
#1168
Comments
getExportedDeclarations
not including re-exported types from external modulesgetExportedDeclarations
not working with yarn PnP
I was able to work around this for now by using yarn's patch protocol to require |
I have this problem too after upgrading Yarn to the latest version and switching to the default PnP mode. @dsherret Is there an official solution on the horizon? |
It looks like this popular package can help. https://www.npmjs.com/package/ts-pnp I wasn't able to figure out yet how to set ts-morphs Project.resolutionHost property to make use of this. |
It seems like the way ts-morph imports typescript cannot be effected by yarn PnP api. From this comment ts-morph decided to include typescript bundle as hard-copy. Because yarn enables PnP by patching typescript, including typescript like this way (not by using package json - So patching // in ts-morph-common.js
const ts = require('./typescript') // this one point out hard-copied typescript
// change to
const ts = require('typescript') // I'm not sure if ts-morph should change this behavior, to support yarn pnp. Anyway this kind of bundle process (hard copy typescript dist file) is not regular way as I know, so we should think about it (although the comment said there was a |
Yeah like @jwoo0122 and @AlCalzone said, yarn patch protocol + redirecting the import works.
- var ts = require('./typescript');
+ var ts = require('typescript');
packageExtensions:
+ "@ts-morph/common@*":
+ peerDependencies:
+ typescript: "*"
+ "ts-morph@*":
+ peerDependencies:
+ typescript: "*"
You could change a few things, like patching the |
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, becausegetExportedDeclarations()
is returning an empty array for re-exported types from another package of the monorepo. Many other types have becomeany
.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.
eb20fcb
yarn add --dev ts-morph
(so yarn PnP doesn't barf at you)repro.ts
with the following content in the root:yarn node -r ts-node/register repro.ts
Expected behavior
decl
should be an array with length 1, including the original symbol forValueID
.The text was updated successfully, but these errors were encountered: