syntax-tree/unist-builder

Remove the String cast for the node's value

kamikazePT opened this issue · 2 comments

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

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?

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.