-
Notifications
You must be signed in to change notification settings - Fork 89
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
JSON.parse[@@customMatcher]? #310
Comments
The latter seems like it'd be really brittle with various formatting options, and the former seems pretty expensive. Even if we could make it make sense, I'm not sure we'd want to encourage people to do this - also, we should definitely never encourage anyone to hand-write a JSON string. |
The example is just to clarify what the input is. In real life it might be like this: const file = await readFile()
const config = match (file) {
JSON.parse({ let config and isValidConfig }): config;
Yaml.parse({ let config and isValidYamlConfig }): config;
default: throw new Error()
} |
that seems like if would attempt to YAML-parse JSON that didn't match the expected schema - i'm not sure this can be shoehorned into pattern matching cleanly tbh. |
Just for readability, I don't think attaching the custom matcher to I could see installing it on |
Yes, but iirc @rbuckton doesn't like it because |
While i don’t think we should restrict ourselves to only see matching as the inverse of |
because tryParse isn't a thing now, I wonder if we can have JSON.parse[@@customMatcher] to allow matches JSON structure inside a string.
or if it should be "reflective", it might be on
stringify
The text was updated successfully, but these errors were encountered: