You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use Monaco as a built-in editor for JavaScript in a custom software solution. The saved JavaScript will run in a context where an API is available. I am trying to get good intellisense support in the editor. I have been able to create a sourcefile with class definitions for the API and include it into the editor using monaco.languages.typescript.javascriptDefaults.addExtraLib. This works well, and I am able to create new instances of classes and get intellisense (Ctrl+Space) for methods/members when the variables are declared e.g. like this: "const person = new Person()". However, our API has a lot of factory methods returning class instances, such as "const person = personAgent.CreateNewPerson();". Since function returns in JavaScript can be whatever, I understand that it is difficult (impossible) to evaluate the correct variable type in this scenario. However, since I know that it will be a "Person", I would like to indicate this to the editor to get proper intellisense. In TypeScript it is straight forward of course, but we have to stick to JavaScript in our solution. I know that VSCode supports JSDoc type annotations (/* @type Person */), but I am unable to make this work in Monaco. I also read somewhere that JSDoc is not supported in Monaco. Any information on how to make this work is highly appreciated :-)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I am trying to use Monaco as a built-in editor for JavaScript in a custom software solution. The saved JavaScript will run in a context where an API is available. I am trying to get good intellisense support in the editor. I have been able to create a sourcefile with class definitions for the API and include it into the editor using monaco.languages.typescript.javascriptDefaults.addExtraLib. This works well, and I am able to create new instances of classes and get intellisense (Ctrl+Space) for methods/members when the variables are declared e.g. like this: "const person = new Person()". However, our API has a lot of factory methods returning class instances, such as "const person = personAgent.CreateNewPerson();". Since function returns in JavaScript can be whatever, I understand that it is difficult (impossible) to evaluate the correct variable type in this scenario. However, since I know that it will be a "Person", I would like to indicate this to the editor to get proper intellisense. In TypeScript it is straight forward of course, but we have to stick to JavaScript in our solution. I know that VSCode supports JSDoc type annotations (/* @type Person */), but I am unable to make this work in Monaco. I also read somewhere that JSDoc is not supported in Monaco. Any information on how to make this work is highly appreciated :-)
Sverre
Beta Was this translation helpful? Give feedback.
All reactions