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

better stringify key in LAZY_IN_SYNC #1511

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

paul-marechal
Copy link
Contributor

Description

  • When LAZY_IN_SYNC is invoked with a symbol it might throw an error because the JS runtime doesn't know how to stringify a symbol on its own for some reason.
  • When passing a function/class as key, then the output gets weird as the JS runtime may return the whole class body when stringifying it.

This PR adjusts the way the key is stringified by:

  • If it's a function then print as [function/class NAME].
  • If it's a symbol then we explicitly convert it to string using symbol.toString() before printing.
  • Wrap with single quotes in a template string.

Related Issue

#1510

Motivation and Context

Better error message.

How Has This Been Tested?

Manually called LAZY_IN_SYNC with a symbol using the node REPL.

Types of changes

  • Updated docs / Refactor code / Added a tests case (non-breaking change)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the changelog.

@PodaruDragos PodaruDragos merged commit 05a9237 into inversify:master Oct 25, 2023
9 checks passed
@paul-marechal paul-marechal deleted the mp/stringify-symbol branch October 27, 2023 01:17
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.

None yet

2 participants