Skip to content

bug(bi-directional-links, inline-link-preview): type error while enabling markdown-it plugin #284

@bingling-sama

Description

@bingling-sama

i was setup bi-directional-links and inline-link-preview:

import { BiDirectionalLinks } from "@nolebase/markdown-it-bi-directional-links"
import { InlineLinkPreviewElementTransform } from "@nolebase/vitepress-plugin-inline-link-preview/markdown-it"


markdown: {
	config: (md) => {
		md.use(BiDirectionalLinks({
			dir: "docs",
			baseDir: "/"
		}))
			.use(InlineLinkPreviewElementTransform)
	},
},

but i got a type error both in vscode and tsc:

.vitepress/config.ts:321:12 - error TS2769: No overload matches this call.
  Overload 1 of 3, '(plugin: PluginSimple): MarkdownIt', gave the following error.
    Argument of type '(md: MarkdownIt) => void' is not assignable to parameter of type 'PluginSimple'.
      Types of parameters 'md' and 'md' are incompatible.
        Type 'MarkdownIt' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/index").default'.
          The types returned by 'inline.ruler.getRules(...)' are incompatible between these types.
            Type 'RuleInline[]' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/parser_inline").RuleInline[]'.
              Type 'RuleInline' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/parser_inline").RuleInline'.
                Types of parameters 'state' and 'state' are incompatible.
                  Type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/rules_inline/state_inline").default' is not assignable to type 'StateInline'.
                    Types of property 'tokens_meta' are incompatible.
                      Type '(import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/rules_inline/state_inline").TokenMeta | null)[]' is not assignable to type '(TokenMeta | null)[]'.
                        Type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/rules_inline/state_inline").TokenMeta | null' is not assignable to type 'TokenMeta | null'.
                          Type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/rules_inline/state_inline").TokenMeta' is not assignable to type 'TokenMeta'.
                            Types of property 'delimiters' are incompatible.
                              Type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/rules_inline/state_inline").Delimiter[]' is not assignable to type 'Delimiter[]'.
                                Property 'jump' is missing in type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/rules_inline/state_inline").Delimiter' but required in type 'Delimiter'.
  Overload 2 of 3, '(plugin: PluginWithOptions<any>, options?: any): MarkdownIt', gave the following error.
    Argument of type '(md: MarkdownIt) => void' is not assignable to parameter of type 'PluginWithOptions<any>'.
      Types of parameters 'md' and 'md' are incompatible.
        Type 'MarkdownIt' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/index").default'.
  Overload 3 of 3, '(plugin: PluginWithParams, ...params: any[]): MarkdownIt', gave the following error.
    Argument of type '(md: MarkdownIt) => void' is not assignable to parameter of type 'PluginWithParams'.
      Types of parameters 'md' and 'md' are incompatible.
        Type 'MarkdownIt' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/index").default'.

321     md.use(BiDirectionalLinks({
               ~~~~~~~~~~~~~~~~~~~~
322      dir: "docs",
    ~~~~~~~~~~~~~~~~~
323      baseDir: "/"
    ~~~~~~~~~~~~~~~~~
324     }))
    ~~~~~~

  node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_npr_fcqhritz7vm5q7fevr55fze57e/node_modules/vitepress/dist/node/index.d.ts:605:5
    605     jump: number;
            ~~~~
    'jump' is declared here.

.vitepress/config.ts:325:11 - error TS2769: No overload matches this call.
  Overload 1 of 3, '(plugin: PluginSimple): MarkdownIt', gave the following error.
    Argument of type 'PluginWithOptions<{ tag: string; } | null | undefined>' is not assignable to parameter of type 'PluginSimple'.
      Types of parameters 'md' and 'md' are incompatible.
        Type 'MarkdownIt' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/index").default'.
  Overload 2 of 3, '(plugin: PluginWithOptions<{ tag: string; } | null>, options?: { tag: string; } | null | undefined): MarkdownIt', gave the following error.
    Argument of type 'PluginWithOptions<{ tag: string; } | null | undefined>' is not assignable to parameter of type 'PluginWithOptions<{ tag: string; } | null>'.
      Types of parameters 'md' and 'md' are incompatible.
        Type 'MarkdownIt' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/index").default'.
  Overload 3 of 3, '(plugin: PluginWithParams, ...params: any[]): MarkdownIt', gave the following error.
    Argument of type 'PluginWithOptions<{ tag: string; } | null | undefined>' is not assignable to parameter of type 'PluginWithParams'.
      Types of parameters 'md' and 'md' are incompatible.
        Type 'MarkdownIt' is not assignable to type 'import("D:/Projects/crashmc.com/node_modules/.pnpm/@[email protected]/node_modules/@types/markdown-it/lib/index").default'.

325      .use(InlineLinkPreviewElementTransform)
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

did i get something wrong or there's some problem in my project configs?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpkg/bi-directional-linksRelated to @nolebase/markdown-it-bi-directional-linkspkg/inline-link-previewRelated to @nolebase/vitepress-plugin-inline-link-previewpkg/thumbnail-hashRelated to @nolebase/vitepress-plugin-thumbnail-hashupstreamBlocked by or related to upstream dependencies

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions