microsoft / microsoft/TypeScript

Leading JSDoc `*` in type expression incorrectly parsed

Open
#38,290 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: JSDoc
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

I tried the following snippet

/**
 * @typedef {
 *   import('../src/index.js').FakeCloudwatchLogs
 * } FakeCloudwatchLogs
 */

This did not compile with

test/index.js:11:6 - error TS1005: '}' expected.

11  *   import('../src/index.js').FakeCloudwatchLogs
        ~~~~~~

Removing the * and writing

/**
 * @typedef {
     import('../src/index.js').FakeCloudwatchLogs
 * } FakeCloudwatchLogs
 */

Does compile.

I am using typsecript 3.8.3

There is a related issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue from test/index.js using the reported TypeScript 3.8.3 snippet and compare it with the version that omits the leading *. Trace the JSDoc typedef parsing entry point to determine why the comment prefix is treated as part of the type expression; done means both forms compile without the TS1005 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.