Skip to content
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

[Bug] TypeScript 4.2.2 unable to be installed with Yarn 2.4.0 #2514

Closed
jacobwgillespie opened this issue Feb 24, 2021 · 14 comments
Closed

[Bug] TypeScript 4.2.2 unable to be installed with Yarn 2.4.0 #2514

jacobwgillespie opened this issue Feb 24, 2021 · 14 comments
Labels
bug Something isn't working reproducible This issue can be successfully reproduced

Comments

@jacobwgillespie
Copy link

Describe the bug

It appears that when attempting to install TypeScript 4.2, which was just released, the latest released version of Yarn (2.4.0) fails to apply patches. Attempting to install or upgrade TypeScript results in the error Cannot apply hunk #6.

It does appear that the unreleased code in master (yarn set version from sources) is able to install TypeScript 4.2.2.

To Reproduce

Note that since this is only an issue for 2.4.0, this reproduction downloads and runs against 2.4.0 rather than master:

Reproduction
const {execFile} = require('child_process');
const {promisify} = require('util');
const execFileP = promisify(execFile);

// Install the latest released version of Yarn
await yarn('set', 'version', 'latest');

// Add helper to call the released version
async function yarnLatest (...args) {
  let stdout;
  try {
    ({stdout} = await execFileP('.yarn/releases/yarn-2.4.0.cjs', args, {
      env: {...process.env, YARN_ENABLE_COLORS: 0, YARN_IGNORE_PATH: 1, YARN_ENABLE_INLINE_BUILDS: 1},
    }));
  } catch (error) {
    error.message += `\n${error.stdout}`;
    throw error;
  }
  return stdout;
}

// Init the local project
await yarnLatest('init');

// Attempt to install TypeScript
const installPromise = yarnLatest('add', 'typescript');
await expect(installPromise).resolves.toBeDefined();

Screenshots

Screenshot 2021-02-24 at 14 25 10

Environment

  • OS: macOS
  • Node version: 14.15.5
  • Yarn version 2.4.0
@jacobwgillespie jacobwgillespie added the bug Something isn't working label Feb 24, 2021
@yarnbot yarnbot added the reproducible This issue can be successfully reproduced label Feb 24, 2021
@yarnbot

This comment has been minimized.

@arcanis
Copy link
Member

arcanis commented Feb 24, 2021

Unfortunately as long as microsoft/TypeScript#35206 isn't merged we have to rely on a patch in order to add TypeScript compatibility. Such patches sometimes fail to apply cleanly between versions, and that's what happened here.

On the bright side this particular issue has already been fixed in master, so running yarn set version from sources may be an option for you (although beware, the master branch has a few potentially breaking changes). We'll soon release 3.0.0-rc.1 which will include the fix.

And remember to upvote the TS PR, perhaps a critical mass will convince the TS team to partner on a proper fix 🤞

@jacobwgillespie
Copy link
Author

Nice, yea I'm already one of the 90+ upvotes on that PR 👍 🙃

yarn set version from sources does resolve, but I don't necessarily want to upgrade our business projects to a bleeding edge version just yet. We're happy to wait for a released version of Yarn and block on upgrading TypeScript, if it's not practical to resolve on the 2.x Yarn branch.

@JTrippleP
Copy link

Beat me to the post!
On the bright side, 4.1.5 is still working so I will be sticking to that until Microsoft adds in official support (hopefully).
I'll get my co-workers to add some upvotes on that.

Thanks

@SimenB
Copy link

SimenB commented Feb 24, 2021

Is there any way of skipping the patch if I use the node_modules linker? I don't need PnP support, but I would like to update to TS 4.2.

I guess this applies to all the patches you bundle

@Eli-Black-Work
Copy link

In some cases, this error can be worked around by adding these lines to package.json:

"resolutions": {
   "typescript": "4.1.5"
}

Specifically, this is useful when you're seeing this error because one of your dependencies depends on TypeScript 4.2.2 but your project doesn't.

Hope that's helpful to someone 🙂

@arcanis arcanis mentioned this issue Feb 25, 2021
3 tasks
@arcanis
Copy link
Member

arcanis commented Feb 25, 2021

Is there any way of skipping the patch if I use the node_modules linker? I don't need PnP support, but I would like to update to TS 4.2.

I guess this applies to all the patches you bundle

I'll add this capability to the next release.

@SimenB
Copy link

SimenB commented Feb 25, 2021

Awesome, thanks @arcanis!

@sportshead
Copy link

The link for the error message doesn't work, perhaps a section can be added with a link to this issue?

@araujogui
Copy link
Contributor

Use typescript@~4.1.5 as long as there is no fix to the issue.

@clemyan
Copy link
Contributor

clemyan commented Mar 2, 2021

Use typescript@~4.1.5 as long as there is no fix to the issue.

Not directly related to the issue, but as a rule of thumb typescript should be specified with ~ everywhere because its versioning scheme is non-semver.

@JasonKleban

This comment has been minimized.

@arcanis
Copy link
Member

arcanis commented Mar 2, 2021

@JasonKleban This seems to be a different issue, please open a different thread (with reproduction).

I'll lock this thread for now since the resolution is already in progress (fix is already in master, and with #2543 failing builtin patches won't prevent you from using the packages - the patch will simply be turned off). I'll update once a release is made (ideally we'll make a 2.4.1 that will just include the TS fix, I just have to double-check that the branch didn't diverge too much).

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Mar 2, 2021
@arcanis
Copy link
Member

arcanis commented Mar 2, 2021

I've just released Yarn 2.4.1, which formally fixes the compatibility issue with TS 4.2 (no other change in this release). Along with the work mentioned in the previous post I think we can now close this issue, thanks for your patience!

@arcanis arcanis closed this as completed Mar 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working reproducible This issue can be successfully reproduced
Projects
None yet
Development

No branches or pull requests

10 participants