-
-
Notifications
You must be signed in to change notification settings - Fork 23
feat(language-service): Make MDX nodes typed with JSX.IntrinsicElements #515
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi! It seems some of the things asked in the template are missing? Please edit your post to fill out everything.
You won’t get any more notifications from me, but I’ll keep on updating this comment, and remove it when done! If you need it, here’s the original template<!--
Please check the needed checkboxes ([ ] -> [x]).
Leave the comments as they are: they do not show on GitHub.
Please try to limit the scope,
provide a general description of the changes,
and remember it’s up to you to convince us to land it.
We are excited about pull requests.
Thank you!
-->
### Initial checklist
* [ ] I read the support docs <!-- https://mdxjs.com/community/support/ -->
* [ ] I read the contributing guide <!-- https://mdxjs.com/community/contribute/ -->
* [ ] I agree to follow the code of conduct <!-- https://github.com/mdx-js/.github/blob/main/code-of-conduct.md -->
* [ ] I searched issues and discussions and couldn’t find anything or linked relevant results below <!-- https://github.com/search?q=user%3Amdx-js&type=issues and https://github.com/orgs/mdx-js/discussions -->
* [ ] I made sure the docs are up to date
* [ ] I included tests (or that’s not needed)
### Description of changes
TODO
<!--do not edit: pr-->
Thanks, |
f871eb3
to
f0dc9b8
Compare
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.
The code looks great, but the tests need to be adjusted, notably the tests in https://github.com/mdx-js/mdx-analyzer/blob/main/packages/language-service/test/language-plugin.js.
@@ -789,7 +831,7 @@ function getEmbeddedCodes( | |||
} | |||
|
|||
default: { | |||
jsx += jsxIndent + '</>' | |||
jsx += jsxIndent + getJsxNodeNameForMdast(node).map((name) => `</${name}>`).join('') |
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.
jsx += jsxIndent + getJsxNodeNameForMdast(node).map((name) => `</${name}>`).join('') | |
jsx += jsxIndent + getJsxNodeNameForMdast(node).toReversed().map((name) => `</${name}>`).join('') |
Initial checklist
Description of changes
This PR tries to map MDX Markdown node to correct JSX node. The feature request is at https://github.com/orgs/mdx-js/discussions/2639 . Before, the MDX node are translated to
<></>
fragment in language service, which is not typed well (see microsoft/TypeScript#62358) and this PR changes them to a slightly corrected translation, such as<p></p>
.Benefit on this, we can do type-checking on JSX expression 'hole' inside Markdown contents, such as (e.g. translate to React JSX):
Important This PR is not be able to merged now, since I cannot make tests pass -- it changes too many to the code generation and those asserts will failed quickly.
Also some open questions:
listItem { paragraph { innerContent } }
for a compact list item, which is not the correct behavior according to CommonMark spec (says no<p>
inside a<li>
may not work;