Typescript: Multiline JSDoc Types

Created on 31 May 2017  ·  7Comments  ·  Source: microsoft/TypeScript

From https://github.com/Microsoft/vscode/issues/27777

Issue
For the javascript:

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

The type of x is any. It seems multiline types are not recognized in jsdocs

There seems to be some debate about whether this is supported or not: https://github.com/jscs-dev/node-jscs/issues/245 but it seems closure and some other tools support the multiline syntax

Also tracking syntax highlighting for this case here: https://github.com/Microsoft/TypeScript-TmLanguage/issues/467

JSDoc Fixed In Discussion Suggestion VS Code Tracked

Most helpful comment

AFAIK this is fixed now.

All 7 comments

As a workaround, it may help to delete the leading * characters on the lines in between {{ and }}. Assuming your linter will let you.

@seanf did not seem to help in my use-cases; would be great if this were built in without needing an explicit linter (since jsdoc technically already accepts multiline params)

@rob2d can you post an example of the code you couldn't get to work? I tried @mjbvz's example, and after deleting the leading asterisks, the type works:

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

Not skipping leading asterisk is a known bug #23667. You may have found a different bug.

AFAIK this is fixed now.

@weswigham is it?

With VSCode Version 1.30.1:

screen shot 2019-01-04 at 11 54 12

AFAIK the syntax highlighting is still waiting on https://github.com/atom/language-javascript/pull/515

Yes, I found this link a bit after asking about it. Thanks!

Was this page helpful?
0 / 5 - 0 ratings