Bug: rehypeShikiFromHighlighter has bad type
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
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
Source: shikijs/shiki