Typescript: Debug failure in getLiteralTypeFromPropertyName

Created on 8 Mar 2018  路  12Comments  路  Source: microsoft/TypeScript

TypeScript Version: 2.8.0-dev.20180308

Code

// @Filename: /a.ts
import x = require("something");
export { x };

// @Filename: /b.ts
import a = require('./a');
declare function f<T>(obj: T, key: keyof T): void;
f(a, "");

Expected behavior:

No error.

Actual behavior:

  1) compiler tests
       compiler tests for tests/cases/compiler/foo.ts
         "before all" hook:
     Error: Debug Failure. False expression: Target symbol and symbol do not have the same name
      at getLiteralTypeFromPropertyName (src\compiler\checker.ts:8014:27)
      at Object.map (src\compiler\core.ts:422:29)
      at getLiteralTypeFromPropertyNames (src\compiler\checker.ts:8027:33)
      at getIndexType (src\compiler\checker.ts:8036:17)
      at instantiateType (src\compiler\checker.ts:9028:28)
      at getTypeOfInstantiatedSymbol (src\compiler\checker.ts:4628:32)
      at getTypeOfSymbol (src\compiler\checker.ts:4656:24)
      at getTypeOfParameter (src\compiler\checker.ts:18243:26)
      at getTypeAtPosition (src\compiler\checker.ts:18256:53)
      at checkApplicableSignature (src\compiler\checker.ts:16964:39)
      at chooseOverload (src\compiler\checker.ts:17548:30)
      at resolveCall (src\compiler\checker.ts:17407:26)
      at resolveCallExpression (src\compiler\checker.ts:17650:20)
      at resolveSignature (src\compiler\checker.ts:17945:28)
      at getResolvedSignature (src\compiler\checker.ts:17978:28)
      at checkCallExpression (src\compiler\checker.ts:18043:31)
      at checkExpressionWorker (src\compiler\checker.ts:19758:28)
      at checkExpression (src\compiler\checker.ts:19690:44)
      at checkExpressionStatement (src\compiler\checker.ts:22220:13)
      at checkSourceElement (src\compiler\checker.ts:24332:28)
      at Object.forEach (src\compiler\core.ts:179:32)
      at checkSourceFileWorker (src\compiler\checker.ts:24515:17)
      at checkSourceFile (src\compiler\checker.ts:24489:13)
      at Object.forEach (src\compiler\core.ts:179:32)
      at getDiagnosticsWorker (src\compiler\checker.ts:24591:13)
      at getDiagnostics (src\compiler\checker.ts:24554:24)
      at Object.getEmitResolver (src\compiler\checker.ts:808:13)
      at emitWorker (src\compiler\program.ts:1180:71)
      at src\compiler\program.ts:1131:51
      at runWithCancellationToken (src\compiler\program.ts:1253:24)
      at Object.emit (src\compiler\program.ts:1131:20)
      at Object.compileFiles (src\harness\harness.ts:1231:40)
      at Context.<anonymous> (src\harness\compilerRunner.ts:116:49)
Bug Fixed

Most helpful comment

Hi, facing the same issue. Is there a workaround for this issue other that pinning to 2.7.x? Thank you for your help.

All 12 comments

@weswigham Looks like this is caused by #22339 -- broken in 16bf02991d181373779e0e33552e016a8f194a3a but works in the previous commit 53ae50754563890f5eb409f4c613939652b250e5

FYI I am seeing this same error in typescript@rc. I will try to create a small repro case from my huge code base. If I can do that, do you want me to add it as a comment on this issue, or open a new issue (referencing this one)?

We removed the assertion in question yesterday, it won't be there in the 2.8 release.

@weswigham @mhegazy this change is still present in the 2.8 release - I am seeing the error 馃槼 . https://unpkg.com/[email protected]/lib/typescript.js contains the string "Target symbol and symbol do not have the same name" - is it possible there was an issue when the release was created?

@mhegazy did we cut 2.8 before the associated PR was merged?

@weswigham @mhegazy my apologies, I misread https://github.com/Microsoft/TypeScript/issues/22403#issuecomment-373806137 - I see that this fix will be in the next release.

Hi, facing the same issue. Is there a workaround for this issue other that pinning to 2.7.x? Thank you for your help.

@sberan you mean in the TS2.8.2 release?

@nicojs I misparsed the " it won't be there in the 2.8 release" statement - this definitely is still an issue in 2.8.1 and is blocking my project from upgrading to TS 2.8.

@cah-sberan looks like you are running into a different issue. can you share more context. can you share a sample project that we can debug against?

@mhegazy #22920 definitely fixes my issue, it will be in the 2.8.2 release. Cheers!

No, @mhegazy this didn't hit the 2.8 release, so is likely the same issue. It's in the 2.8 branch now (so will be in 2.8.2), but AFAIK the release branch was cut before it was merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlaberge picture dlaberge  路  3Comments

blendsdk picture blendsdk  路  3Comments

weswigham picture weswigham  路  3Comments

siddjain picture siddjain  路  3Comments

manekinekko picture manekinekko  路  3Comments