Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
IceCreamYou opened this issue Sep 11, 2022 · 0 comments · Fixed by #50724
Closed
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue

Comments

@IceCreamYou
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue
Projects
None yet
4 participants