JS Noob - does not understand error of monaco editor

I have the following code:

client.reverse(msg.payload).then((/** @type {any} */ output) => {
    msg.payload = output;

}).catch((/** @type {{ name: any; message: any; }} */ err) => {
    // An error has been returned by the Promise.
    // Do something with it...
    msg.payload = {
        name: err.name,
        message: err.message

If the comment is not added you get the following error or warning with the monaco editor:

With the quick fix a comment is added, but why does this fix the error. Sorry I am a noob in JS.

OK - i guess I found it out - it is something using JSDoc.

However if you specify a wrong type in this description - no error is raised.

That is not an error but rather a warning. Just ignore it if you know the data types are correct. Monaco/VScode does its best with data typing but sometimes it just can't work it out.

BTW, there is a known issue in Monaco when trying to force in-line JSDoc style typing. Generally you need to wrap the variable or statement you want to type in ( ... ) in order for Monaco to know that it should actually be applied.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.