tree-sitter-cli
tree-sitter-cli copied to clipboard
Use Object cast for safe property access
Without these you'll get one of these errors TypeError: Cannot read property 'constructor' of undefined or TypeError: Cannot read property 'constructor' of null.
Oh thanks for catching that; that's a really bad error message.
Regarding the implementation, it seems a bit more straightforward to just explicitly check for value is null (or undefined)
if (value == null) {
throw new Error('Missing rule value');
}
switch (value.constructor) {
// ...
}
Thoughts?
Yes, that's a good idea. But I didn't want to change anything, especially not throw new errors.
But if you think it's better I can change it.