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

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

Closed
bingling-sama opened this issue Jul 28, 2024 · 3 comments · Fixed by #289
Assignees
Labels
bug Something isn't working pkg/bi-directional-links Related to @nolebase/markdown-it-bi-directional-links pkg/inline-link-preview Related to @nolebase/vitepress-plugin-inline-link-preview pkg/thumbnail-hash Related to @nolebase/vitepress-plugin-thumbnail-hash upstream Blocked by or related to upstream dependencies

Comments

@bingling-sama
Copy link

bingling-sama commented Jul 28, 2024

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?

@nekomeowww
Copy link
Member

Noticed that.

Related to:

HanochMa/vitepress-markdown-timeline#1
vuejs/vitepress#3772
vuejs/vitepress#3856
nolebase/nolebase#51

Was fixed at #228, and #240 (yes twice)

Yet the offcial @types/markdown-it and vitepress is now incompatible again... they just changed the types again last week at DefinitelyTyped/DefinitelyTyped#70117 .

I will fix this in the next release.

@nekomeowww nekomeowww added bug Something isn't working upstream Blocked by or related to upstream dependencies pkg/inline-link-preview Related to @nolebase/vitepress-plugin-inline-link-preview pkg/thumbnail-hash Related to @nolebase/vitepress-plugin-thumbnail-hash pkg/bi-directional-links Related to @nolebase/markdown-it-bi-directional-links labels Jul 31, 2024
@nekomeowww nekomeowww self-assigned this Jul 31, 2024
@bingling-sama
Copy link
Author

Great, i really appreciate it.

@nekomeowww
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg/bi-directional-links Related to @nolebase/markdown-it-bi-directional-links pkg/inline-link-preview Related to @nolebase/vitepress-plugin-inline-link-preview pkg/thumbnail-hash Related to @nolebase/vitepress-plugin-thumbnail-hash upstream Blocked by or related to upstream dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants