berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug]: Compatibility issue with TS 5.6

Open Ayc0 opened this issue 10 months ago • 3 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

When i'm using yarn 4.6.0 with TS 5.6+ and project references, I'm having this error:

.pnp.cjs(223414,7): error TS2527: The inferred type of 'FakeFS' references an inaccessible 'this' type. A type annotation is necessary.

Would it be possible to add a @ts-expect-error / @ts-ignore just before the FakeFS class definition? (like what we have in a few other types?)

To reproduce

I don't have any way of reproducing it sorry :/

Environment

System:
    OS: macOS 15.3
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 20.15.1 - /private/var/folders/4x/njndj3qs3xl4q1my615mt_jh0000gq/T/xfs-c9175b01/node
    Yarn: 4.6.0 - /private/var/folders/4x/njndj3qs3xl4q1my615mt_jh0000gq/T/xfs-c9175b01/yarn
    npm: 10.7.0 - ~/.volta/tools/image/node/20.15.1/bin/npm
    bun: 1.1.45 - /opt/homebrew/bin/bun

Additional context

No response

Ayc0 avatar Feb 12 '25 07:02 Ayc0

Hmm... The PnP hook should not be typechecked at all because it should be marked as // @ts-nocheck. Can you verify whether your PnP hook has it?

clemyan avatar Mar 18 '25 15:03 clemyan

@clemyan I indeed have @ts-nocheck in it, but it's required by another file that is included in the TS project

To fix this, we added .pnp.cjs to the exclude of the project, and switched the require('./.pnp.cjs') to require(('./.pnp.cjs')) (somehow the double (()) skips the type check)

Ayc0 avatar Mar 19 '25 09:03 Ayc0

I'm wondering if there is something more we could do here, like having a .pnp.d.ts or similar

Ayc0 avatar Mar 19 '25 09:03 Ayc0