Why are there no warning/error messages when there are syntax errors?
Why are there no warning/error messages when there are syntax errors?

This isn't isolated to DataTables/Editor but seems to be pretty standard with javascript/jquery. I just spend the last few hours wondering why I couldn't get the inline Editor to submit the entire row even though I had the submit option set to "allIfChanged". Eventually I realized I had transposed two letters:
formOptions: {
inline: {
onBlur: 'submit',
sumbit: 'allIfChanged'
}
}
It got me wondering why there are no warnings generated in the console when there are obvious errors such as this.
This question has an accepted answers - jump to answer
Answers
Hi @InsanelyOne ,
The thing is, that's not an obvious error as such. All you're doing is adding an element
sumbit
to theinline
object, since you can extend objects with any additional elements, that's entirely justified. I agree it can lead to stressful debugging, we've all shared that pain, but it is valid!Cheers,
Colin
Thanks for the insight. Can you give me a real world example where I would want to extend the inline object with an additional element?
I think Colin's point is that we simply mark
submit
as a string, and therefore it could take any value and in future we might offer other options. If Javascript had anenum
type then it would be correct to use it in this case, but it doesn't. We could put in catches for this sort of error for every parameter, but I'm worried about the size of the file.This is somewhere that TypeScript would really help - it would catch that as a compiler error and tell you exactly what the issue is. Unfortunately we don't yet have Typescript definitions for Editor (or indeed official ones for DataTables), but I've been doing a lot of TypeScript work recently and this is something that is very much on my todo list.
Allan
Allan, thanks for the detailed explanation.