Skip to content

tsc crashes when it sees a JSDoc tag inside an @override annotation (regression in TS 4.8) #50717

Closed
@IceCreamYou

Description

@IceCreamYou

Bug Report

This code compiles successfully in TypeScript 4.7.4 and crashes tsc in TypeScript 4.8.2 and 4.8.3 (I did not test 4.8.0 or 4.8.1):

class A {
    doIt() {
        console.log('to it');
    }
}

class B extends A {
    /**
     * @override {@linkcode A.doIt}
     */
    doIt() {
        console.log('harder better faster stronger');
    }
}

The error is:

/home/circleci/project/node_modules/typescript/lib/tsc.js:98438
                throw e;
                ^

Error: Debug Failure. False expression.
    at resolveNameHelper (/home/circleci/project/node_modules/typescript/lib/tsc.js:41391:30)
    at resolveName (/home/circleci/project/node_modules/typescript/lib/tsc.js:41165:20)
    at resolveEntityName (/home/circleci/project/node_modules/typescript/lib/tsc.js:42353:42)
    at resolveEntityName (/home/circleci/project/node_modules/typescript/lib/tsc.js:42361:33)
    at resolveJSDocMemberName (/home/circleci/project/node_modules/typescript/lib/tsc.js:73458:30)
    at checkJSDocLinkLikeTag (/home/circleci/project/node_modules/typescript/lib/tsc.js:69370:17)
    at checkSourceElementWorker (/home/circleci/project/node_modules/typescript/lib/tsc.js:72827:28)
    at checkSourceElement (/home/circleci/project/node_modules/typescript/lib/tsc.js:72726:17)
    at /home/circleci/project/node_modules/typescript/lib/tsc.js:72925:25
    at Object.forEach (/home/circleci/project/node_modules/typescript/lib/tsc.js:124:30)

Putting another JSDoc tag inside an @override is incorrect, so it's fine for the compiler to complain about it, but the stack trace is not very helpful in tracking down what is happening.

In the codebase in which I encountered this error, the method this was decorating (the equivalent of B.doIt in the example above) had an override keyword, so the @override JSDoc tag was just for documentation, making this error even more surprising. The documentation was added before the override keyword was added to TypeScript. I fixed it by changing the tag to @see.

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions 4.7.4 and 4.8.2

⏯ Playground Link

Playground link with relevant code

🙁 Actual behavior

tsc crashed

🙂 Expected behavior

tsc ignores @override JSDoc tags in comments or reports a more friendly error or warning when @override is invalid

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 issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions