-
Notifications
You must be signed in to change notification settings - Fork 7
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
Update marked package #1116
Update marked package #1116
Conversation
packages/base/markdown.gts
Outdated
function toHtml(markdown: string | null) { | ||
return markdown ? sanitizeHtml(marked(markdown, markdownOpts)) : ''; | ||
return markdown ? sanitizeHtml(marked(markdown) as string) : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to cast this? What type does TypeScript think it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return type says string | Promise<string>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why it might be a promise. sounds like there is a potential we might be leaking async here unless we await...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's only async if the options are set to be { async: true } or if any of the options return async. Here's what the docs say: https://marked.js.org/using_pro#async
Thoughts? Just setting the async options to explicitly be false didn't work for glint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we create a wrapper function markedSync
which asserts that the provided options are not async and then casts the result to a string, so we don't have casting all over the place?
Deprecated options were causing a lot of warning messages.