Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc type annotations work in VSCode but not Monaco #203

Closed
greggman opened this issue Sep 26, 2016 · 14 comments · May be fixed by OutSystems/monaco-editor#10
Closed

JSDoc type annotations work in VSCode but not Monaco #203

greggman opened this issue Sep 26, 2016 · 14 comments · May be fixed by OutSystems/monaco-editor#10
Assignees

Comments

@greggman
Copy link

monaco-editor npm version: 0.6.1
Browser: All
OS: all

If I put this code in VSCode 1.5.3

/** @type {WebGLRenderingContext} */
var gl = canvas1.getContext("webgl");

/** @type {CanvasRenderingContext2D} */
var ctx = canvas1.getContext("2d");

Both gl and ctx will get the correct auto-completion for their respective types but the same code does not get auto completions in Monaco. Note: Monaco does know the definitions of WebGLRenderingContext and CanvasRenderingContext2D as I can type WebGLRenderingContext.prototype. and see all the completions.

Is this a feature I just need to enable? Is it just not yet pulled from VSCode? Or is it a feature that's not meant to be part of Monaco?

@alexdima
Copy link
Member

Hmm, it's a surprise for me too. @jrieken any ideas?

I've also found function annotations to not be working

/**
 * @returns {string}
 */
function f() {
    return canvas1;
}

@jrieken
Copy link
Member

jrieken commented Sep 27, 2016

We ship different versions of TypeScript in the standalone editor and VS Code

@greggman
Copy link
Author

greggman commented Sep 27, 2016

Meaning if I just upgrade the monaco TypeScript support to the same version in VS Code it will start working? Or, meaning the stuff in VS Code is not compatible with Monaco?

@greggman
Copy link
Author

Well if you're curious I added the monaco editor to http://webglfundamentals.org. All of the examples run in a codepen style editor using monaco. Every sample has this at the top

  /** @type {HTMLCanvasElement} */
  var canvas = document.getElementById("canvas");
  var gl = canvas.getContext("webgl");

If monaco supported type annotations like VSCode then from that both canvas and gl would support all the intellisense like functions.

If there's a way to make that work that would be great.

@nkev
Copy link

nkev commented Dec 27, 2016

@jrieken is there any progress with this issue?

@jrieken
Copy link
Member

jrieken commented Jan 16, 2017

closing as dupe of #177

@jrieken jrieken closed this as completed Jan 16, 2017
@greggman
Copy link
Author

greggman commented Feb 3, 2017

I'm confused how #177 relates to this. #177 is closed saying the project is now on TypeScript 2.1 but this issue, issue #203 still doesn't work.

Is there's a way to make it work? Or if not could you please re-open this issue?

@alexdima
Copy link
Member

alexdima commented Feb 3, 2017

I can confirm JSDoc annotations still don't work.

@jrieken Perhaps there is more to getting them work than updating to TS 2.1

@alexdima alexdima reopened this Feb 3, 2017
@jonnermut
Copy link

Is there any way to hint Monaco of the type of a given function parameter dynamically (eg without modifying the editor source) ?
I tried dynamically creating a d.ts for a given function signature, but when you declare that function in the editor it treats it as an override, and ignores the type information I added.
See
http://stackoverflow.com/questions/43037243/provide-type-hints-to-monaco-editor

@kitsonk
Copy link

kitsonk commented Jun 18, 2017

I have added a PR in monaco-typescript. The providers for monaco-editor are greatly simplified from the language features for vscode. In vscode there is now further abstraction away from the language services which also extractions the documentation and tags from the quick info and returns them from the hover provider.

@jonnermut
Copy link

@kitsonk I had a quick look at your PR ( microsoft/monaco-typescript#14 ), I don't think it actually fixes this issue, which is about having the Monaco know the type of a parameter from the JSDoc annotations, so that code complete / intellisense works on that parameter?

@jrieken
Copy link
Member

jrieken commented Jun 19, 2017

screen shot 2017-06-19 at 11 13 45

This works for me (without microsoft/monaco-typescript#14) on master. It is important to know that this is supported in JS files only and the we interpret files as JS when they have an uri-path that ending in .js like some/path/some/file.js. When no ending is available make sure to use the allowJs-compiler setting

@jrieken
Copy link
Member

jrieken commented Jun 19, 2017

The fix for this (microsoft/monaco-typescript@9b5c885) will be in the next release.

@jrieken jrieken closed this as completed Jun 19, 2017
@jonnermut
Copy link

Cool. Just to confirm @jrieken, a and b will have code complete within the body of foo()?

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants