Skip to content

Multiline JSDoc Types #467

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

Closed
mjbvz opened this issue May 31, 2017 · 4 comments
Closed

Multiline JSDoc Types #467

mjbvz opened this issue May 31, 2017 · 4 comments

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 31, 2017

From microsoft/vscode#27777

TS and JS Grammar Extension version: 0.0.20

Code

/**
 * @param {{
 *  z: number
 * }} x
 */
function foo(x){}

Current highlighting:

screen shot 2017-05-31 at 2 49 02 pm

There seems to be some debate about whether this is supported or not: jscs-dev/node-jscs#245 but it seems closure supports this syntax

@sheetalkamat
Copy link
Member

sheetalkamat commented Jun 2, 2017

We used the jsdoc grammar from https://github.com/atom/language-javascript. Please file the issue there and once fixed we will pick it up. Thank you.

mjbvz added a commit to mjbvz/TypeScript-TmLanguage that referenced this issue Apr 8, 2019
Fixes microsoft#467

Adds a begin/while rule so that doc blocks also consume the leading *. This approach has been used by VS Code to support highlighting example blocks (see microsoft#693)

Remove the `invalid.illegal.type.jsdoc` rule since we now can highlight multiline types better
@Raynos
Copy link

Raynos commented May 12, 2020

Can we re-open this issue ? The upstream repository is not maintained anymore ( atom/language-javascript#645 (comment) )

Any changes to the jsdoc grammar to support multiline syntax highlighting wil lhave to be made directly in this repository.

@jeremyjacob
Copy link

Seconded. The issue is still present, despite support for multiline JSDoc types at the LSP level.
image

@myfonj
Copy link

myfonj commented Feb 29, 2024

+1. Rephrasing info from linked issue (microsoft/vscode#206516), even simple line break before closing */ of "line" JSDoc comment makes it appear like a normal insignificant comment:

/** @type {string} */
var a = "OK, highlighted as JSDoc.";
/** @type {string}
*/
var b = "ERROR, highlighted like a regular comment.";

Produces:
First comment is highlighted, second is not.

And this code monster demonstrating that LSP crunches it without a problem, but highlighter fails:

JavaScript code from following snippet showing hover tooltip inside typedef proving it is processed and error lens errors after var statements.

// @ts-check

/** @typedef
    * {
    typeof
    * ABC [
         number
    * ]
    }
           *       Ch -
   this
 - still
 * works
*/
// ↑ ERROR, highlighted as a comment, but processed

const ABC = /** @type {const} */(["a", "b", "c"]);
	
/** @type {Ch}
*/
// ↑ ERROR, highlighted as a comment, but processed
var x = 'd';

/** @type {Ch} */
// ↑ OK, highlighted
var y = 'd';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants