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

@types in peerDeps #119

Open
undefined-moe opened this issue Sep 26, 2022 · 2 comments
Open

@types in peerDeps #119

undefined-moe opened this issue Sep 26, 2022 · 2 comments

Comments

@undefined-moe
Copy link

currently, @types/markdown-it was marked as a peerDependency, however in production mode, @types shouldn't be installed, and package manager throws a peerDep missing warning.

I think "@types/markdown-it": "*" should be placed into devDeps, and package managers would automatically choose which version to install (always reuse existing @types/markdown-it installed by outer project first if possible, and in this case, all versions are compatible)

@valeriangalliat
Copy link
Owner

Sadly that's a general problem with TypeScript packages depending on @types definitions

If I put it in devDependencies then people who include markdown-it-anchor in their TypeScript projects won't have the @types/ packages of the undelying packages we depend on (here @types/markdown-it).

We depend on @types/markdown-it for the types of markdown-it-anchor:

import MarkdownIt = require('markdown-it');
import Token = require('markdown-it/lib/token');
import State = require('markdown-it/lib/rules_core/state_core');

But it's also correct that if I put it in dependencies or peerDependencies like it's the case now, the types are installed in production where they are not necessarily needed.

We would need to introduce a new kind of dependency in the ecosystem, e.g. devPropagateDependencies (I'm bad at naming things), that would be installed in the parent projects in development (unlike devDependencies which wouldn't be installed at all), but not in production (unlike dependencies and peerDependencies)

This is documented here and discussed here and here

I really wish there was another way! Let me know if you find anything on that :)

@undefined-moe
Copy link
Author

We depend on @types/markdown-it for the types of markdown-it-anchor:

If people want types, they want type for both markdown-it core and plugin, and they should install them all.

markdown-it-anchor strictly depends on markdown-it, which means:

  • If you are in development mode, then you should install markdown-it (peerDeps), and if you need types, as you are using MarkdownIt().use(), you should install @types/markdown-it already (as outer devDeps)
  • If you are running in production, everything is built to javascript, and types are useless, no need to install them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants