berry: [Bug]: typescript patch fails to apply with typescript@4.5

Self-service

  • I’d be willing to implement a fix

Describe the bug

This is replicable on first install only — on subsequent uninstall/reinstalls of typescript@^4.5.1-rc, the install appears to succeed but the symptoms still persist.

$ yarn add --dev typescript@^4.5.1-rc
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0s 815ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ typescript@npm:4.5.1-rc can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ typescript@patch:typescript@npm%3A4.5.1-rc#~builtin<compat/typescript>::version=4.5.1-rc&hash=ddd1e8 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ typescript@npm:4.5.1-rc can't be found in the cache and will be fetched from the remote registry
➤ YN0066: │ typescript@patch:typescript@npm%3A4.5.1-rc#~builtin<compat/typescript>::version=4.5.1-rc&hash=ddd1e8: Cannot apply hunk #2
➤ YN0000: └ Completed in 22s 379ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 23s 511ms
$ yarn tsc --noEmit

[snip]

[snip].ts:3:17 - error TS2307: Cannot find module '[snip]' or its corresponding type declarations.

3 import [snip] from "[snip]";
                      ~~~~~~


Found 24 errors.

To reproduce

$ yarn add --dev typescript@^4.5.1-rc
{
  "devDependencies": {
    "typescript": "^4.5.1-rc",
  }
}

Environment

System:
    OS: macOS 12.0
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 16.12.0 - /private/var/folders/zk/9kgkd8tx4fq9ptvlc7cc8f0c0000gn/T/xfs-59651938/node
    Yarn: 3.1.0 - /private/var/folders/zk/9kgkd8tx4fq9ptvlc7cc8f0c0000gn/T/xfs-59651938/yarn
    npm: 8.1.3 - ~/.npm/bin/npm

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 17
  • Comments: 22 (7 by maintainers)

Commits related to this issue

Most upvoted comments

The updated patch was released in 3.2.0-rc.5

yarn set version canary && yarn install

For those yarn set version canary && yarn install does not work, ts2307 error could be occurred due to typescript configuration of your IDE. If you are using vscode try the command below.

yarn add -D @yarnpkg/pnpify
yarn dlx @yarnpkg/sdks vscode

and the reference is here

Stable 3.1.1 has been released

yarn set version latest && yarn install

This issue occurs in typescript@4.5.2 that causes cannot find module "" in every import statement.

I downgraded typescript to 4.4.4 to workaround this issue.

yarn set version canary did not fix it for me (Windows 19043.1348, WSL 2 Ubuntu)

This worked though (thanks @Paosder):

This issue occurs in typescript@4.5.2 that causes cannot find module "" in every import statement.

I downgraded typescript to 4.4.4 to workaround this issue.

In case someone needs help downgrading:

yarn remove typescript
rm -rf .yarn/sdks/typescript
yarn add typescript@4.4.4
yarn dlx @yarnpkg/sdks base

yarn 3.1.0

That indicates you didn’t run the provided commands

@DanielHoffmann You’re running into https://github.com/yarnpkg/berry/issues/4157 which is unrelated to this issue.

The updated patch was released in 3.2.0-rc.5

yarn set version canary && yarn install

This did not work for me (yarn 3.1.0, typescript: 4.5.2) I downgraded to typescript 4.4.4 and it’s work well

Those warnings is showing up after the upgrade because of https://github.com/yarnpkg/berry/pull/3667, I plan on silencing them as they provide no value but for now you can use --no-warnings

NODE_OPTIONS="--no-warnings" yarn lint

Running yarn set version canary && yarn install as suggested by @merceyz worked for me! I can now use TS 4.5.2 with PnP in https://github.com/kachkaev/njt/pull/161 🎉

There is a bunch of --experimental-loader warnings after the update, both for node --version v16.13.0 and v17.1.0.

Screenshot 2021-11-21 at 21 21 10

Is there any practical workaround? The warnings are not blocking, they just distract from other (possibly more useful) output.

I did not… But I did just duplicate my working folder and upgraded back to typescript 4.5.2-sdk and it’s all working fine… so presumably running yarn install after yarn set version canary would have worked. Sorry for the noise.