-
- Notifications
You must be signed in to change notification settings - Fork 658
Description
Describe the bug
When integrating @blocknote/core + @blocknote/code-block with a custom Shiki bundle, the type of CodeBlockOptions["createHighlighter"] from @blocknote/core is not compatible with the createHighlighter function returned by the Shiki packages that @blocknote/code-block depends on.
Concretely:
-
@blocknote/coredepends on@shikijs/types@3.13.0and exposes:// node_modules/@blocknote/core/types/src/blocks/Code/block.d.ts import type { HighlighterGeneric } from "@shikijs/types"; export type CodeBlockOptions = { // ... createHighlighter?: () => Promise<HighlighterGeneric<any, any>>; };
-
@blocknote/code-blockdepends on Shiki packages that pull in@shikijs/types@3.19.0(in my app this is deduped tonode_modules/@shikijs/types@3.19.0).
This means:
CodeBlockOptions["createHighlighter"]expects aHighlighterGenericcoming from@blocknote/core/node_modules/@shikijs/types@3.13.0- My custom Shiki bundle returns a
HighlighterGenericcoming fromnode_modules/@shikijs/types@3.19.0
Even though the runtime shape is compatible, TypeScript treats these as two different, incompatible types, so I have to use as any to satisfy the BlockNote API.
To Reproduce
- Install BlockNote core and code-block (current version):
npm install @blocknote/core@0.44.2 @blocknote/code-block@0.44.2In the BlockNote repo, packages/core/package.json still has
"@shikijs/types": "3.13.0", while packages/code-block/package.json
pulls in Shiki packages that resolve to @shikijs/types@3.19.0 in my app.
-
Generate a custom Shiki bundle with
shiki-codegenand use it from your app -
Wire this highlighter into BlockNote:
codeBlock: createCodeBlockSpec({ // Workaround: required due to @shikijs/types version mismatch createHighlighter: () => createHighlighter({ themes: ["light-plus", "dark-plus"], langs: [], }) as any, }),
-
Run TypeScript (
tsc) – you will get a type error unless you addas anyto thecreateHighlightercall.
Misc
- Node version: v24.12.0
- Package manager: npm 11.6.2
- Browser: -
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖