markdown-exit icon indicating copy to clipboard operation
markdown-exit copied to clipboard

types incompatible with markdown-it

Open Mister-Hope opened this issue 8 months ago • 3 comments

Problem

I understand that markdown-exit is a rewritten version of markdown-it, and types are expected to be stricter.

But I am receiving issues like https://github.com/mdit-plugins/mdit-plugins/issues/396, which is definitely not my job to fix unless I am maintaining a "markdown-exit-plugins" repo.

Suggest solution

Since markdown-exit is claiming to support markdown-it plugins, I would suggest markdown-exit itself handle the type itself.

The mdExit.use() should accept a dual signature; one is a stricter type with MarkdownExit, and it should add @types/markdownit as a dep and allow another loose type with MarkdownIt.

If you do want the .use() API to be stricter, consider providing a .useLegacy API to explicitly allow plugins that are using markdown-it types.

Mister-Hope avatar Mar 17 '26 01:03 Mister-Hope

Another possible solution is that releasing a separate type package (e.g.: @markdown-exit/types) with better types than the original markdown-it.

The package can be used by plugin maintainers like me, and the types must satisfy both markdown-it and markdown-exit.

Currently I believe I have no motivation to drop support of markdown-it by requiring markdown-exit totally.

Mister-Hope avatar Mar 17 '26 01:03 Mister-Hope

I need some time to think this through. Shipping with @types/markdown-it as a dependency might not be the best approach, and for now I’m leaning toward using as unknown / any as a temporary workaround.

serkodev avatar Mar 17 '26 09:03 serkodev

I need some time to think this through. Shipping with @types/markdown-it as a dependency might not be the best approach, and for now I’m leaning toward using as unknown / any as a temporary workaround.

Consider providing a useLegacy(md: MarkdownIt, options: any) as a use wrapper plz, then declare @types/markdown-it as an optional peer. This should avoid introducing markdown-it types into the project for true markdown-exit users and still remain fully compatible with original ecosystem.

Mister-Hope avatar May 29 '26 03:05 Mister-Hope