Skip to content

Multiline JSDoc function signatures aren't properly parsed #26846

Closed
@tschaub

Description

@tschaub

TypeScript Version: 3.1.0-dev.20180901

Search Terms:

  • JSDoc
  • function
  • multiline
  • asterisk

Code

/**
 * A function whose signature is very long.
 *
 * @typedef {function(boolean, string, number):
 *     (string|number)} StringOrNumber
 */

/**
 * Makes use of a function type with a long signature.
 * @param {StringOrNumber} func The function.
 * @param {boolean} bool The condition.
 * @param {string} str The string.
 * @param {number} num The number.
 * @returns {string|number} The return.
 */
function check(func, bool, str, num) {
  return func(bool, str, num)
}

Expected behavior:

tsc --pretty reports no errors.

Actual behavior:

main.js:5:8 - error TS1005: '}' expected.

5  *     (string|number)} StringOrNumber
         ~

main.js:10:12 - error TS2304: Cannot find name 'StringOrNumber'.

10  * @param {StringOrNumber} func The function.
              ~~~~~~~~~~~~~~

Related Issues:

This is a variation of #23667 and in the same family as #26027 and #26774. Also pretty similar to #25779.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions