Skip to content

fix: support markdown-it v15 types alongside v13/v14 - #11

Open
ArcticLampyrid wants to merge 1 commit into
made-in-common:mainfrom
ArcticLampyrid:fix/markdown-it-v15-types
Open

ArcticLampyrid wants to merge 1 commit into
made-in-common:mainfrom
ArcticLampyrid:fix/markdown-it-v15-types

Conversation

@ArcticLampyrid

Copy link
Copy Markdown

Summary

markdown-it v15 ships built-in TypeScript declarations and no longer exports PluginWithOptions (which came from @types/markdown-it). As a result, consumers using markdown-it v15 encounter a type error when importing markdown-it-github-alerts.

This PR updates the plugin type signature to use InstanceType<typeof MarkdownIt> from the default markdown-it import instead of PluginWithOptions:

declare function MarkdownItGitHubAlerts(
  md: InstanceType<typeof MarkdownIt>,
  options?: MarkdownItGitHubAlertsOptions,
): void
  • Works with markdown-it v15 (built-in types, where the default export is a callable constructor value and PluginWithOptions is absent).
  • Remains fully compatible with markdown-it v13 and v14 (@types/markdown-it).
  • Adds a type assertion for tokens[idx].meta so src/index.ts also typechecks under markdown-it v15's stricter Token.meta type (Record<string, unknown> | null).

Verification

  • Passed pnpm lint, pnpm typecheck, pnpm build, and pnpm test in this repository.
  • Verified the generated dist/index.d.mts with tsc --noEmit --strict --skipLibCheck false under both moduleResolution: "bundler" and "nodenext" across:
    • markdown-it@15.0.3 (no @types/markdown-it)
    • markdown-it@14.1.0 + @types/markdown-it@14.1.2
    • markdown-it@14.1.0 + @types/markdown-it@14.2.0
    • markdown-it@13.0.2 + @types/markdown-it@13.0.9

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

Successfully merging this pull request may close these issues.

1 participant