-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
(parser) Public API methods should validate input types better #2631
Comments
We probably could do better here, but if someone was going to tackle this I'd want a PR that dealt with ALL the public API methods, not just the "issue of the day"... ie fix the whole problem (I've renamed the issue accordingly) I'd prefer not to add a ton of validation clutter to the codebase either - we have a lot of API public methods - I'd want to wrap this kind of thing up in some type of nice abstraction: // just a rough idea
validateTypes("highlight", arguments,
["languageName", "code", "ignoreIllegals","continuation"],
{
languageName: "string",
code: "string",
ignoreIllegals: "boolean?",
continuation: "object?"
}) This raises a few questions:
I'm not opposed to this - if it's done nicely/properly - but we've also managed without it for forever, so I'd say it's not the highest priority IMHO. Leaving this open to continue the discussion. |
This work would pair well with #2277 |
Periodic issue review. This type of feature is really not helpful once code is in production - and would only add bloat while providing zero or almost zero benefit. It would make some sense perhaps in a debug or development build - which isn't something we currently have. I'm not sure it's worth creating another build target (dev) just to add run-time type validation. Setting this to auto-close. |
Running
hljs.highlightAuto(1)
Result:
it happend when I forget to use .toString() in below code on
buffer
:fix:
ensure code param is in correct type (string) otherwise return error (it's not string, type is X)
The text was updated successfully, but these errors were encountered: