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

Fix MDXContent to allow missing props #83

Merged
merged 5 commits into from
Sep 8, 2021
Merged

Conversation

mike-mcdonald
Copy link
Contributor

Adjusts MDXContent function output to allow undefined props as a parameter without throwing a TypeError.

Closes #82

* Make sure logical and is applied to Object.assign call within MDXContent function
@wooorm
Copy link
Owner

wooorm commented Sep 7, 2021

Sweet, thanks for working on this!

I think it would be better to solve it in the argument list: MDXContent(props = {}).
Reasoning is that it’s documented that props is an object in one example of the readme: https://github.com/wooorm/xdm#mdx-content.

Also, could you update the example in the readme following “The actual output of running node example.js is:”?

There are also two errors in the tests on CI. the babel one looks a bit flakey (I’ll check if that’s still the case), but the error message might need to be changed?

@wooorm
Copy link
Owner

wooorm commented Sep 7, 2021

ps. run npm test locally to test your changes! And you can use ASTExplorer to figure out what the AST is for certain JS code

@wooorm
Copy link
Owner

wooorm commented Sep 7, 2021

Rebasing your PR against main should solve the weird babel error

@wooorm
Copy link
Owner

wooorm commented Sep 7, 2021

The other error was related due to a change in Node 16.9. Updates the tests to fix that as well.

@mike-mcdonald
Copy link
Contributor Author

@wooorm Sounds like a plan. I'll adjust the fix to provide a default value for the props parameter and work on the test errors.

@mike-mcdonald mike-mcdonald changed the title Use logical and to avoid TypeError when props is undefined Adjust MDXContent function to avoid TypeError when props is undefined Sep 7, 2021
@mike-mcdonald
Copy link
Contributor Author

@wooorm I've updated my branch with your changes to main and am able to run npm run test locally with no failures now!

@wooorm wooorm changed the title Adjust MDXContent function to avoid TypeError when props is undefined Fix MDXContent to allow missing props Sep 8, 2021
@wooorm wooorm merged commit bebab6d into wooorm:main Sep 8, 2021
@wooorm
Copy link
Owner

wooorm commented Sep 8, 2021

Thanks, released!

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.

Vue Router calls generated MDXContent function without props parameter, causing TypeError
2 participants