Open undefined-moe opened 1 year ago
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: https://github.com/valeriangalliat/markdown-it-anchor/blob/8918e4eba26df9b13819acde5a9bf4e4fb8d9816/types/index.d.ts#L1-L3
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 :)
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:
markdown-it
(peerDeps), and if you need types, as you are using MarkdownIt().use()
, you should install @types/markdown-it
already (as outer devDeps)
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)