Is it possible to set argument types in JS functions for code completion?
-
Hi,
For example. When I declare this variable:function baseHttpRequest(endPoint, onDoneCallback, onErrorCallback) { var request = new XMLHttpRequest(); request.onreadystatechange = function() { if (request.readyState === XMLHttpRequest.DONE) { if (request.status === 200) { onDoneCallback(request); } else { onErrorCallback(request); } } } }
Qt Creator in this context know variable type and when I type
request.
(dot), it suggest object properties etc. But when I pass this object in function argument:function myFunction( req: XMLHttpRequest ) { }
then when I type
req.
I don't see any suggestions which is expected due to JavaScript nature. I'm also getting this warning:
[object Object] should be coerced to void because the function called is insufficiently annotated. The original value is retained. This will change in a future version of Qt
So we must wait or is there any workaround / trick in QML world? My workaround is split wanted values from object as base types:onErrorCallback(status: int, statustext: string, content: string);
I know that this topic is stupid for java scripters which are used to but I'm "typed" programmer and I like to see types :P