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

Remove the String cast for the node's value #12

Closed
4 tasks done
kamikazePT opened this issue May 4, 2023 · 2 comments
Closed
4 tasks done

Remove the String cast for the node's value #12

kamikazePT opened this issue May 4, 2023 · 2 comments
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on

Comments

@kamikazePT
Copy link

Initial checklist

Problem

I have some use cases in which I would need the value to be an actual value, not cast to string, to work around this I ended up making my own unist-builder without the String() call.

I don't even understand why we want to force string to it, if it's a value, we can even map it or filter it using the unist-filter and unist-map utilities without having to parse/stringify the value.

Solution

builder shouldn't hard cast to string the value provided, since it limits how we can use the value itself while mixing with other syntax-tree utilities.

Alternatives

  • JSON.parse when needed, which isn't much of a good alternative
@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 4, 2023
@wooorm
Copy link
Member

wooorm commented May 9, 2023

I have some use cases in which I would need the value to be an actual value,

Why?

why we want to force string

Because these projects are about ASTs. Which represent programming code. So, objects that represent strings. Literals are the smallest possible slice of a document. Hence a string.

JSON.parse

Why do you want to put JSON in there?

@wooorm wooorm closed this as completed Jun 1, 2023
@wooorm wooorm added the 🤷 no/invalid This cannot be acted upon label Jun 1, 2023
@github-actions

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants