question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript as a peerDependency

See original GitHub issue

Are there any reasons this package has so old TypeScript peerDependency? It breaks the build:

 ERROR  @typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree: tsutils@3.21.0 requires a peer of 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 but none was installed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
silverwindcommented, May 17, 2021

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:

eslint-plugin-jest@24.3.6
┬ @typescript-eslint/experimental-utils@4.24.0
└─┬ @typescript-eslint/typescript-estree@4.24.0
  └─┬ tsutils@3.21.0
    └── typescript@4.2.4
5reactions
darekkaycommented, May 6, 2021

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 > tsutils@3.21.0" 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

A tip on using peer dependencies with TypeScript
React is now a peer dependency, which means the main application needs to list it in its own dependencies. Additionally, we're able to...
Read more >
Understanding Peer Dependencies in JavaScript
When to use peerDependencies? Peer dependencies really come into play when you're developing code that will be used by others, such as plugins ......
Read more >
How do I handle optional peer dependencies when publishing ...
When publishing a TypeScript package to npm that provides a function that accepts input from either one peer dependency or another, how do...
Read more >
typescript@ versions and peer dependencies - NPM Peer
Online Peer dependency version tool to search for compatible versions of related NPM packages.
Read more >
peerDependencies are not regarded by import : WEB-51617
It is not possible to use peer dependencies in TypeScript. WebStorm does not recognize them and marks import statement as invalid.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found