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

Update marked package #1116

Merged
merged 4 commits into from
Apr 1, 2024
Merged

Update marked package #1116

merged 4 commits into from
Apr 1, 2024

Conversation

burieberry
Copy link
Contributor

Deprecated options were causing a lot of warning messages.

function toHtml(markdown: string | null) {
return markdown ? sanitizeHtml(marked(markdown, markdownOpts)) : '';
return markdown ? sanitizeHtml(marked(markdown) as string) : '';
Copy link
Contributor

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?

Copy link
Contributor Author

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>

Copy link
Contributor

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...

Copy link
Contributor Author

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

Here are the signatures:
types

Thoughts? Just setting the async options to explicitly be false didn't work for glint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

github-actions bot commented Mar 25, 2024

Test Results

550 tests  ±0   546 ✔️ ±0   8m 30s ⏱️ +24s
    1 suites ±0       4 💤 ±0 
    1 files   ±0       0 ±0 

Results for commit 2c636e4. ± Comparison against base commit 2f163c1.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@lukemelia lukemelia left a 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?

@burieberry burieberry requested a review from lukemelia April 1, 2024 13:40
@burieberry burieberry merged commit 35beb75 into main Apr 1, 2024
22 checks passed
@delete-merged-branch delete-merged-branch bot deleted the cs-6631-marked-pkg-update branch April 1, 2024 14:07
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

Successfully merging this pull request may close these issues.

3 participants