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

"includeExplanation" missing from types on both codeToHtml and codeToTokens #851

Open
3 of 5 tasks
pixeloution opened this issue Nov 27, 2024 · 0 comments
Open
3 of 5 tasks

Comments

@pixeloution
Copy link

pixeloution commented Nov 27, 2024

Validations

Describe the bug

Setting the "includeExplanation" option to true on codeToHtml works as expected but typescript does not recognize it as a valid property. This only causes an error if you use an object literal in the argument, for example:

// typescript error:
// error TS2353: Object literal may only specify known properties, and 'includeExplanation' 
// does not exist in type 'CodeToHastOptions<BundledLanguage, BundledTheme>'
shiki.codeToHtml(code, {
  lang: 'md',
  includeExplanation: true
});

Current workaround, should anyone see this thread before a fix exists, it to simply typecast:

shiki.codeToHtml(code, {
  lang: 'md',
  includeExplanation: true
} as CodeToHastOptions);

I'm unable to provide a patch at this time but the fix is straightforward.

Reproduction

See typescript example above

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant