a, Use type annotations on all JavaScript functions in QML files. Period. It helps tooling, gives you better diagnostics from qmllint and qmlsc, helps you understand your code better. There are no downsides.

b, In this particular case we could be more lenient, but what if that was actually an unrelated "contains" method? Mind that you can shadow those methods by inheriting or by mixing C++ and QML. If we get the wrong one, we can probably still JavaScript-coerce the argument to point and the return value to bool, but the result will be a mess and rather hard to debug.

c, The change that introduced the containment masks, https://codereview.qt-project.org/c/qt/qtdeclarative/+/211550 , only intended the contains() functions to be defined in C++. Later, starting with https://codereview.qt-project.org/c/qt/qtdeclarative/+/249400 , we've added type annotations for JavaScript functions. Using those you can now define typed functions in JavaScript and they are treated the same way as C++ functions. So, be happy that this works at all ;)
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to