Skip to content

Debug Failure in invalid JSDoc type expression #47537

Closed
@gabritto

Description

@gabritto

Bug Report

If we have invalid JSDoc like in the example below, we get a Debug Failure. Did not expect TypeLiteral to have an Identifier in its trivia when calling service functions e.g. getSyntacticClassifications on a span containing the bad jsdoc.

🔎 Search Terms

debug failure, Did not expect TypeLiteral to have an Identifier in its trivia

🕗 Version & Regression Information

Probably always.

This is a crash.

⏯ Playground Link

Playground link with relevant code

💻 Code

class I18n {
   /**
    * @param {{dot|fulltext}} [stringMode] - which mode our translation keys use
    */
   constructor(options = {}) {}
}

The bad JSDoc is the part inside the param's type expression: {dot|fulltext}.

🙁 Actual behavior

Crash:

| Error: Debug Failure. Did not expect TypeLiteral to have an Identifier in its trivia
|     at addSyntheticNodes (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160370:30)
|     at createSyntaxList (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160386:13)
|     at processNodes (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160349:27)
|     at visitNodes (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:29926:24)
|     at Object.forEachChild (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:30066:24)
|     at NodeObject.forEachChild (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160324:23)
|     at createChildren (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160358:14)
|     at NodeObject.getChildren (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160301:56)
|     at processElement (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:128482:47)
|     at processElement (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:128486:25)

🙂 Expected behavior

No crash.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issueOld-Crawler-DetectedDetected by an older crawler (aka "fuzzer") running random TSServer operations on public code.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions