#985·shiki

Bug: rehypeShikiFromHighlighter has bad type

Author: Its-AlexCreated Apr 4, 2025Updated Mar 20, 2026

Validations

Describe the bug

Hello

Using the fine grained example of shiki with rehype my type checker is throwing an error:

Argument of type '[HighlighterCore, { inline: "tailing-curly-colon"; theme: "dracula"; }]' is not assignable to parameter of type '[boolean] | [highlighter: HighlighterGeneric<any, any>, options: RehypeShikiCoreOptions]'.
  Type '[HighlighterCore, { inline: "tailing-curly-colon"; theme: "dracula"; }]' is not assignable to type '[highlighter: HighlighterGeneric<any, any>, options: RehypeShikiCoreOptions]'.
    Type at position 0 in source is not compatible with type at position 0 in target.
      Type 'HighlighterCore' is not assignable to type 'HighlighterGeneric<any, any>'.
        Type 'any' is not assignable to type 'never'.

I think there is an incompatibility of type using rehypeShikiFromHighlighter that require HighlighterGeneric<any, any> as a first argument and createHighlighterCore that return Promise<HighlighterCore> or Promise<HighlighterGeneric<never, never>>.

From what I can understand HighlighterGeneric<never, never> can't be validated because never can't be used on any. Am I correct?

If necessary I think I can try to update the type of HighlighterGeneric to allow any and never has arguments in a PR, don't know if this will be easy to correct tests.

Thanks for your time

Reproduction

You can reproduce if you execute pnpm check in this repository this is a sveltekit minimal project.

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests