Skip to content

noUnusedLocals with allowJS and checkJS causes error #21533

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

Closed
natedanner opened this issue Feb 1, 2018 · 12 comments
Closed

noUnusedLocals with allowJS and checkJS causes error #21533

natedanner opened this issue Feb 1, 2018 · 12 comments

Comments

@natedanner
Copy link

TypeScript Version: 2.7.1

Search Terms:
checkJS, unusedlocals, tsc.js:59841

Code

Run: tsc test.js --noUnusedLocals --checkJS --allowJS --noEmit
With

class MyClass {

	doSomething() {
	};
}

Expected behavior:
No errors introduced

Actual behavior:
/usr/local/lib/node_modules/typescript/lib/tsc.js:59841
throw e;
^

Error: Debug Failure.
at checkUnusedClassMembers (/usr/local/lib/node_modules/typescript/lib/tsc.js:35757:38)
at checkUnusedIdentifiers (/usr/local/lib/node_modules/typescript/lib/tsc.js:35643:29)
at checkSourceFileWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:37913:21)
at checkSourceFile (/usr/local/lib/node_modules/typescript/lib/tsc.js:37891:13)
at getDiagnosticsWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:37945:17)
at Object.getDiagnostics (/usr/local/lib/node_modules/typescript/lib/tsc.js:37934:24)
at /usr/local/lib/node_modules/typescript/lib/tsc.js:59858:85
at runWithCancellationToken (/usr/local/lib/node_modules/typescript/lib/tsc.js:59834:24)
at getSemanticDiagnosticsForFileNoCache (/usr/local/lib/node_modules/typescript/lib/tsc.js:59848:20)
at getAndCacheDiagnostics (/usr/local/lib/node_modules/typescript/lib/tsc.js:60059:26)

Additional info:
If I remove the semi-colon from the doSomething method or don't pass the --noUnusedLocals flag the error does not appear. I don't get the error in either case on TypeScript version 2.6.2. We are using allowJS/checkJS feature on our legacy JS at my shop and ran into this bug after 2.7.1 upgrade

@ajafff
Copy link
Contributor

ajafff commented Feb 1, 2018

Fixed by #21343?

@natedanner
Copy link
Author

Yep! Test with latest. Closing out.

@ajafff
Copy link
Contributor

ajafff commented Feb 1, 2018

@sandersn might be a good candidate for backporting

@sandersn
Copy link
Member

sandersn commented Feb 1, 2018

Good point @ajafff. It's too late for the official 2.7 release, but it could go into 2.7.2. What do you think, @mhegazy?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 1, 2018

It is already ported. should be released with 2.7.2

@closca
Copy link

closca commented Feb 2, 2018

When will release 2.7.2?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 2, 2018

No specific ETA at the moment. but we plan it to go out sometime in the next two weeks.

@Spongman
Copy link

i think a new release containing just this bug fix would have been a good move.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 15, 2018

2.7.2 should be live now.

@sebsto
Copy link

sebsto commented Apr 16, 2018

I have the same problem with 2.8.1

$ tsc --version
Version 2.8.1
/usr/local/lib/node_modules/typescript/lib/tsc.js:61464
                throw e;
                ^

Error: Debug Failure. False expression: Target symbol and symbol do not have the same name
    at getLiteralTypeFromPropertyName (/usr/local/lib/node_modules/typescript/lib/tsc.js:26752:30)
    at eachPropertyRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28844:36)
    at indexTypesRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28893:36)
    at structuredTypeRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28593:51)
    at recursiveTypeRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28423:53)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28139:38)
    at checkTypeRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:27990:26)
    at checkTypeComparableTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:27717:20)
    at checkAssertionWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:34558:21)
    at checkAssertion (/usr/local/lib/node_modules/typescript/lib/tsc.js:34549:20)

@RyanCavanaugh
Copy link
Member

@sebsto looks like a completely different call stack - can you open a new issue with repro steps? Thanks!

@sebsto
Copy link

sebsto commented Apr 17, 2018

I realized that after posting, new issue and steps to reproduce is here. #23461

@microsoft microsoft locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants