Giter Site home page Giter Site logo

TypeScript as a peerDependency about tsutils HOT 10 CLOSED

 avatar commented on June 9, 2024 2
TypeScript as a peerDependency

from tsutils.

Comments (10)

silverwind avatar silverwind commented on June 9, 2024 7

I too came here through a eslint plugin which through a chain of dependencies and with npm v7 now installing peerDependencies, ends up bloating my node_modules with an unused typescript compiler:

[email protected]
┬ @typescript-eslint/[email protected]
└─┬ @typescript-eslint/[email protected]
  └─┬ [email protected]
    └── [email protected]

from tsutils.

darekkay avatar darekkay commented on June 9, 2024 5

If you don't have TypeScript installed, why would you install this package? Its sole purpose is to simplify using the TypeScript API.

@ajafff One use case: having an eslint-config package that supports different environments conditionally, like JavaScript projects (no TS required) and TypeScript projects at the same time (example). This currently leads to a warning because of tsutils being included in packages like @typescript-eslint/eslint-plugin:

warning "@typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >=
3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".

People keep having this issue because of tsutils, unfortunately:

This is what peerDependenciesMeta was created for:

This allows you to integrate and interact with a variety of host packages without requiring all of them to be installed.

This would be the required change in package.json:

  "peerDependenciesMeta": {
    "typescript": {
      "optional": true
    }
  }

Are you open to such a change?

from tsutils.

 avatar commented on June 9, 2024 1

If you don't care about its version, just make it "typescript": "*"

from tsutils.

ajafff avatar ajafff commented on June 9, 2024

This package has a peerDependency on TypeScript, because it depends on TypeScript being present, but you need to bring your own version of it. (just in case someone reading this doesn't know what a peer dependency is)
It allows any stable version starting from 2.8.0. the rest is there because removing it is a breaking change and there's no need to remove support for old nightly builds.

If you have TypeScript installed and your package manager complains about unmatched version, your package manager is broken.

If you don't have TypeScript installed, why would you install this package? Its sole purpose is to simplify using the TypeScript API.

from tsutils.

 avatar commented on June 9, 2024

@ajafff I'm using TypeScript but its version much newer than you specified in its peerDependencies, hence it does not satisfy the semver.

Please, refer to semantic versioning doc and see that TypeScript v4 does not satisfy your >= v3 condition. The issue is still open.

from tsutils.

 avatar commented on June 9, 2024

If you have TypeScript installed and your package manager complains about unmatched version, your package manager is broken.

cc @zkochan

from tsutils.

zkochan avatar zkochan commented on June 9, 2024

You probably use strict-peer-dependencies

pnpm is not broken. If the typescript version does not match the range specified in peer dependencies and strict-peer-dependencies is set to true, then pnpm will exit with an error.

This might cause an error on npm v7 as well.

from tsutils.

 avatar commented on June 9, 2024

You probably use strict-peer-dependencies

Yes, I prefer fixing warnings, not ignoring them. I have a TypeScript v4 and when configuring typescript-eslint it complain about this package not having it in peerDependency.

from tsutils.

ajafff avatar ajafff commented on June 9, 2024

pnpm is not broken. If the typescript version does not match the range specified in peer dependencies

has anyone taken the time to investigate why typescript@4 would not satisfy >= 2.8.0? I consider that broken behavior

from tsutils.

 avatar commented on June 9, 2024

@ajafff we are considering any option, yes. There are more tools involved, and it is hard to find the culprit.

I checked the semver range here (https://semver.npmjs.com) and I can see that 4.2.4 is satisfied by >= 2.8.0. So it is indeed a strange error not related to this package.

from tsutils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.